Skip to contentSkip to conversation

rbd: make const pointer speaces a static const array

PATCH In review Colin Ian King 3 participants 3 messages Nov 27, 2021 – Nov 30, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rbd: make const pointer speaces a static const array

Don't populate the const array spaces on the stack but make it static const and make the pointer an array to remove a dereference. Shrinks object code a little too. Also clean up intent, currently it is spaces and should be a tab.

---
 drivers/block/rbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/rbd.c +1 -1
index 8f140da1efe3..de7ede6aa95a 100644
@@ -6189,7 +6189,7 @@ static inline size_t next_token(const char **buf)
         * These are the characters that produce nonzero for
         * isspace() in the "C" and "POSIX" locales.
         */
-        const char *spaces = " \f\n\r\t\v";
+	static const char spaces[] = " \f\n\r\t\v";
 
         *buf += strspn(*buf, spaces);	/* Find start of token */
 
Signature · 1 line
2.33.1
#1 lore raw
Quoted 15 lines · Colin Ian King

Don't populate the const array spaces on the stack but make it static const and make the pointer an array to remove a dereference. Shrinks object code a little too. Also clean up intent, currently it is spaces and should be a tab.

---
 drivers/block/rbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/rbd.c +0 -0
index 8f140da1efe3..de7ede6aa95a 100644

drivers/block/rbd.c static inline size_t next_token(const char **buf) · line 6195

Quoted 8 lines
drivers/block/rbd.c +1 -1
@@ -6189,7 +6189,7 @@ static inline size_t next_token(const char **buf)
         * These are the characters that produce nonzero for
         * isspace() in the "C" and "POSIX" locales.
         */
-        const char *spaces = " \f\n\r\t\v";
+	static const char spaces[] = " \f\n\r\t\v";
 
         *buf += strspn(*buf, spaces);	/* Find start of token */
 

Thanks, Colin. Merged into our "testing" branch. It should make v5.17.

Signature · 1 line
Jeff Layton <[email protected]>
#2 lore raw
In reply to Colin Ian King
Quoted 4 lines · Colin Ian King

Don't populate the const array spaces on the stack but make it static const and make the pointer an array to remove a dereference. Shrinks object code a little too. Also clean up intent, currently it is spaces and should be a tab.

[]

drivers/block/rbd.c

Quoted 1 line
drivers/block/rbd.c +0 -0

[]

drivers/block/rbd.c static inline size_t next_token(const char **buf) · line 6195

Quoted 9 lines
drivers/block/rbd.c +1 -1
@@ -6189,7 +6189,7 @@ static inline size_t next_token(const char **buf)
         * These are the characters that produce nonzero for
         * isspace() in the "C" and "POSIX" locales.
         */
-        const char *spaces = " \f\n\r\t\v";
+	static const char spaces[] = " \f\n\r\t\v";
 
         *buf += strspn(*buf, spaces);	/* Find start of token */
 

perhaps

	while (isspace(**buf))
		(*buf)++;

and not have or use spaces at all.