From: Rasmus Villemoes Date: Mon, 23 Mar 2020 18:47:11 +0100 Subject: [PATCH v2] cmd: ubi: add a command to rename volume In-Reply-To: <712753422.1363518.1584983773442.JavaMail.zimbra@softathome.com> References: <1584698111-19384-1-git-send-email-philippe.reynes@softathome.com> <712753422.1363518.1584983773442.JavaMail.zimbra@softathome.com> Message-ID: <748d5984-11bb-df79-0285-57d7b4f9321d@prevas.dk> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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. Rasmus