From mboxrd@z Thu Jan 1 00:00:00 1970 From: Philippe REYNES Date: Mon, 23 Mar 2020 19:24:53 +0100 (CET) Subject: [PATCH v2] cmd: ubi: add a command to rename volume In-Reply-To: <748d5984-11bb-df79-0285-57d7b4f9321d@prevas.dk> References: <1584698111-19384-1-git-send-email-philippe.reynes@softathome.com> <712753422.1363518.1584983773442.JavaMail.zimbra@softathome.com> <748d5984-11bb-df79-0285-57d7b4f9321d@prevas.dk> Message-ID: <1390190722.1402355.1584987893066.JavaMail.zimbra@softathome.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Rasmus, > On 23/03/2020 18.16, Philippe REYNES wrote: > >>>> +#ifdef CONFIG_CMD_UBI_RENAME >>> >>> Can you use IS_ENABLED(CONFIG_...) and drop the #ifdef way above? >> >> I've sent a v3 where I use IS_ENABLED instead of #ifdef. >> But I've kept a #if IS_ENABLED(...) around the function ubi_rename_vol. >> Otherwise if this option is not enabled, there is a warning when building : >> >> CC cmd/ubi.o >> cmd/ubi.c:254:12: warning: 'ubi_rename_vol' defined but not used >> [-Wunused-function] >> static int ubi_rename_vol(char *oldname, char *newname) >> ^~~~~~~~~~~~~~ > > Use C > > if (IS_ENABLED(CONFIG_...) && !strcmp(cmd, "rename")) > > not cpp > > #if IS_ENABLED(CONFIG_...) > if (!strcmp(cmd, "rename")) > > That way the compiler sees ubi_rename_vol is used, but also knows that > it is dead code that can be eliminated. Less ifdeffery (none, actually), > and the code in ubi_rename_vol gets compile coverage regardless of > configuration. Thanks a lot for this explanation. I have sent a v4. And it works as expected, without the #if ... before the function ubi_rename_vol, there isn't a warning if ubi rename is not enabled in the config. > Rasmus Regards, Philippe