lkml.org 
[lkml]   [2015]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] lib/vsprintf.c:Avoid extra operation in dentry_name
From
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


\
 
 \ /
  Last update: 2015-02-16 20:21    [W:0.170 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site