From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752792AbbBQRLw (ORCPT ); Tue, 17 Feb 2015 12:11:52 -0500 Received: from mail-ig0-f180.google.com ([209.85.213.180]:60570 "EHLO mail-ig0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751665AbbBQRLu (ORCPT ); Tue, 17 Feb 2015 12:11:50 -0500 MIME-Version: 1.0 In-Reply-To: References: <1424112583-116849-1-git-send-email-aksgarg1989@gmail.com> Date: Tue, 17 Feb 2015 22:41:49 +0530 Message-ID: Subject: Re: [PATCH] lib/vsprintf.c:Avoid extra operation in dentry_name From: Anshul Garg To: Richard Weinberger Cc: LKML , "anshul.g@samsung.com" , Linus Torvalds Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 wrote: > On Mon, Feb 16, 2015 at 7:49 PM, Anshul Garg wrote: >> From: Anshul Garg >> >> 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 >> --- >> 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