NVDIMM Device and Persistent Memory development
 help / color / mirror / Atom feed
From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "jmoyer@redhat.com" <jmoyer@redhat.com>,
	"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>
Subject: Re: [PATCH ndctl 2/2] libndctl.c: major and minor numbers are unsigned
Date: Mon, 6 May 2024 19:11:47 +0000	[thread overview]
Message-ID: <068777268a0239282b02ed0bc7985f10dd9d4f28.camel@intel.com> (raw)
In-Reply-To: <20240503205456.80004-3-jmoyer@redhat.com>

On Fri, 2024-05-03 at 16:54 -0400, jmoyer@redhat.com wrote:
> From: Jeff Moyer <jmoyer@redhat.com>
> 
> Static analysis points out that the cast of bus->major and bus->minor
> to a signed type in the call to parent_dev_path could result in a
> negative number.  I sincerely doubt we'll see major and minor numbers
> that large, but let's fix it.
> 
> Signed-off-by: Jeff Moyer <jmoyer@redhat.com>

Looks good,
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>

> ---
>  ndctl/lib/libndctl.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
> index ddbdd9a..f75dbd4 100644
> --- a/ndctl/lib/libndctl.c
> +++ b/ndctl/lib/libndctl.c
> @@ -710,11 +710,12 @@ NDCTL_EXPORT void ndctl_set_log_priority(struct
> ndctl_ctx *ctx, int priority)
>  	daxctl_set_log_priority(ctx->daxctl_ctx, priority);
>  }
>  
> -static char *__dev_path(char *type, int major, int minor, int
> parent)
> +static char *__dev_path(char *type, unsigned int major, unsigned int
> minor,
> +			int parent)
>  {
>  	char *path, *dev_path;
>  
> -	if (asprintf(&path, "/sys/dev/%s/%d:%d%s", type, major,
> minor,
> +	if (asprintf(&path, "/sys/dev/%s/%u:%u%s", type, major,
> minor,
>  				parent ? "/device" : "") < 0)
>  		return NULL;
>  
> @@ -723,7 +724,7 @@ static char *__dev_path(char *type, int major,
> int minor, int parent)
>  	return dev_path;
>  }
>  
> -static char *parent_dev_path(char *type, int major, int minor)
> +static char *parent_dev_path(char *type, unsigned int major,
> unsigned int minor)
>  {
>          return __dev_path(type, major, minor, 1);
>  }


      reply	other threads:[~2024-05-06 19:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-03 20:54 [PATCH ndctl 0/2] fix errors pointed out by static analysis jmoyer
2024-05-03 20:54 ` [PATCH ndctl 1/2] ndctl/keys.c: don't leak fd in error cases jmoyer
2024-05-06 19:11   ` Verma, Vishal L
2024-05-03 20:54 ` [PATCH ndctl 2/2] libndctl.c: major and minor numbers are unsigned jmoyer
2024-05-06 19:11   ` Verma, Vishal L [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=068777268a0239282b02ed0bc7985f10dd9d4f28.camel@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=jmoyer@redhat.com \
    --cc=nvdimm@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).