From: Jeff Moyer <jmo...@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 <jmo...@redhat.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);
 }
-- 
2.43.0


Reply via email to