* [PATCH] lib/vsprintf.c:Avoid extra operation in dentry_name
@ 2015-02-16 18:49 Anshul Garg
2015-02-16 19:14 ` Richard Weinberger
0 siblings, 1 reply; 3+ messages in thread
From: Anshul Garg @ 2015-02-16 18:49 UTC (permalink / raw)
To: linux-kernel; +Cc: aksgarg1989, anshul.g, torvalds
From: Anshul Garg <aksgarg1989@gmail.com>
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.
Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
---
lib/vsprintf.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index ec337f6..2a38105 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -576,11 +576,10 @@ char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_sp
if (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) {
--
1.7.9.5
---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lib/vsprintf.c:Avoid extra operation in dentry_name
2015-02-16 18:49 [PATCH] lib/vsprintf.c:Avoid extra operation in dentry_name Anshul Garg
@ 2015-02-16 19:14 ` Richard Weinberger
2015-02-17 17:11 ` Anshul Garg
0 siblings, 1 reply; 3+ messages in thread
From: Richard Weinberger @ 2015-02-16 19:14 UTC (permalink / raw)
To: Anshul Garg; +Cc: LKML, anshul.g, Linus Torvalds
On Mon, Feb 16, 2015 at 7:49 PM, Anshul Garg <aksgarg1989@gmail.com> wrote:
> From: Anshul Garg <aksgarg1989@gmail.com>
>
> 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.
>
> Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
> ---
> lib/vsprintf.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index ec337f6..2a38105 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -576,11 +576,10 @@ char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_sp
> if (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) {
What if the if (d == d) branch is not taken?
Does the code then really behave exactly as before?
--
Thanks,
//richard
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] lib/vsprintf.c:Avoid extra operation in dentry_name
2015-02-16 19:14 ` Richard Weinberger
@ 2015-02-17 17:11 ` Anshul Garg
0 siblings, 0 replies; 3+ messages in thread
From: Anshul Garg @ 2015-02-17 17:11 UTC (permalink / raw)
To: Richard Weinberger; +Cc: LKML, anshul.g, Linus Torvalds
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.
On Tue, Feb 17, 2015 at 12:44 AM, Richard Weinberger
<richard.weinberger@gmail.com> wrote:
> On Mon, Feb 16, 2015 at 7:49 PM, Anshul Garg <aksgarg1989@gmail.com> wrote:
>> From: Anshul Garg <aksgarg1989@gmail.com>
>>
>> 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.
>>
>> Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
>> ---
>> lib/vsprintf.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
>> index ec337f6..2a38105 100644
>> --- a/lib/vsprintf.c
>> +++ b/lib/vsprintf.c
>> @@ -576,11 +576,10 @@ char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_sp
>> if (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) {
>
> What if the if (d == d) branch is not taken?
> Does the code then really behave exactly as before?
>
> --
> Thanks,
> //richard
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-02-17 17:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-16 18:49 [PATCH] lib/vsprintf.c:Avoid extra operation in dentry_name Anshul Garg
2015-02-16 19:14 ` Richard Weinberger
2015-02-17 17:11 ` Anshul Garg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.