lib/vsprintf.c:Avoid extra operation in dentry_name
Subsystems (2)
PATCH 1/1 lib/vsprintf.c:Avoid extra operation in dentry_name
From: Anshul Garg <[email protected]>
Remove unnecessary increment and decrement operation in dentry_name function as after increment operation loop is breaked and then decrement operation is performed. So remove increment and decrement operation from the function.
--- lib/vsprintf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
lib/vsprintf.c +1 -2
@@ -576,11 +576,10 @@ char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_spif (p == d) {if (i) array[i] ="" ; - i++;break ; } } - s = array[--i]; + s = array[i];for (n =0 ; n != spec.precision; n++, buf++) {char c = *s++;if (!c) {
Signature · 6 lines
1.7.9.5 --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com
Quoted 20 lines · Anshul Garg
From: Anshul Garg <[email protected]>
Remove unnecessary increment and decrement operation in
dentry_namefunction as after increment operation loop is breaked and then decrement operation is performed. So remove increment and decrement operation from the function.Signed-off-by Anshul Garg <[email protected]>--- lib/vsprintf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)lib/vsprintf.c +0
-0@@ -576,11 +576,10 @@ char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_spif (p == d) {if (i)
lib/vsprintf.c char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_sp · line 585
Quoted 10 lines
lib/vsprintf.c +1
-2array[i] ="" ; - i++;break ; } } - s = array[--i]; + s = array[i];for (n =0 ; n != spec.precision; n++, buf++) {char c = *s++;if (!c) {
What if the if (d == d) branch is not taken? Does the code then really behave exactly as before?
Signature · 2 lines
Thanks, //richard
Yes suggested code modification will break if (p==d) branch is not taken. Thanks for pointing out this point.
So its better to keep code as it is.
Quoted 38 lines · Richard Weinberger
Quoted 20 lines · Anshul Garg
From: Anshul Garg <[email protected]>
Remove unnecessary increment and decrement operation in
dentry_namefunction as after increment operation loop is breaked and then decrement operation is performed. So remove increment and decrement operation from the function.Signed-off-by Anshul Garg <[email protected]>--- lib/vsprintf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)lib/vsprintf.c +0
-0@@ -576,11 +576,10 @@ char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_spif (p == d) {if (i)lib/vsprintf.c char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_sp · line 585
Quoted 10 lines
lib/vsprintf.c +1
-2array[i] ="" ; - i++;break ; } } - s = array[--i]; + s = array[i];for (n =0 ; n != spec.precision; n++, buf++) {char c = *s++;if (!c) {What if the if (d == d) branch is not taken? Does the code then really behave exactly as before?
--
Thanks,
//richard