[ndctl,1/4] util/abspath: cleanup prefix_filename
diff mbox series

Message ID 20191018202302.8122-2-jmoyer@redhat.com
State New
Headers show
Series
  • misc. cleanups
Related show

Commit Message

Jeff Moyer Oct. 18, 2019, 8:22 p.m. UTC
Static checkers complain about the unused assignment to pfx_len.
The code can obviously be simplified.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 util/abspath.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Ira Weiny Oct. 18, 2019, 8:55 p.m. UTC | #1
On Fri, Oct 18, 2019 at 04:22:59PM -0400, Jeff Moyer wrote:
> Static checkers complain about the unused assignment to pfx_len.
> The code can obviously be simplified.
> 
> Signed-off-by: Jeff Moyer <jmoyer@redhat.com>

Reviewed-by: Ira Weiny <ira.weiny@intel.com>

> ---
>  util/abspath.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/util/abspath.c b/util/abspath.c
> index 09bbd27..e44236f 100644
> --- a/util/abspath.c
> +++ b/util/abspath.c
> @@ -9,11 +9,7 @@ char *prefix_filename(const char *pfx, const char *arg)
>  	struct strbuf path = STRBUF_INIT;
>  	size_t pfx_len = pfx ? strlen(pfx) : 0;
>  
> -	if (!pfx_len)
> -		;
> -	else if (is_absolute_path(arg))
> -		pfx_len = 0;
> -	else
> +	if (pfx_len && !is_absolute_path(arg))
>  		strbuf_add(&path, pfx, pfx_len);
>  
>  	strbuf_addstr(&path, arg);
> -- 
> 2.19.1
> _______________________________________________
> Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
> To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

Patch
diff mbox series

diff --git a/util/abspath.c b/util/abspath.c
index 09bbd27..e44236f 100644
--- a/util/abspath.c
+++ b/util/abspath.c
@@ -9,11 +9,7 @@  char *prefix_filename(const char *pfx, const char *arg)
 	struct strbuf path = STRBUF_INIT;
 	size_t pfx_len = pfx ? strlen(pfx) : 0;
 
-	if (!pfx_len)
-		;
-	else if (is_absolute_path(arg))
-		pfx_len = 0;
-	else
+	if (pfx_len && !is_absolute_path(arg))
 		strbuf_add(&path, pfx, pfx_len);
 
 	strbuf_addstr(&path, arg);