ryantimwilson / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone
65878a
From fbf1747793446a4779dbd503ba07d3e0cb3cd360 Mon Sep 17 00:00:00 2001
65878a
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
65878a
Date: Sun, 15 Dec 2013 16:26:27 -0500
65878a
Subject: [PATCH] Fix a few signed/unsigned format string issues
65878a
65878a
Since numbers involved are all small, behaviour was correct already.
65878a
65878a
https://bugzilla.redhat.com/show_bug.cgi?id=1043304
65878a
---
65878a
 src/shared/time-util.c         |  2 +-
65878a
 src/udev/udev-builtin-net_id.c | 21 +++++++--------------
65878a
 2 files changed, 8 insertions(+), 15 deletions(-)
65878a
65878a
diff --git a/src/shared/time-util.c b/src/shared/time-util.c
65878a
index 81d4ede..d31401b 100644
65878a
--- a/src/shared/time-util.c
65878a
+++ b/src/shared/time-util.c
65878a
@@ -382,7 +382,7 @@ void dual_timestamp_deserialize(const char *value, dual_timestamp *t) {
65878a
         assert(value);
65878a
         assert(t);
65878a
 
65878a
-        if (sscanf(value, "%lli %llu", &a, &b) != 2)
65878a
+        if (sscanf(value, "%llu %llu", &a, &b) != 2)
65878a
                 log_debug("Failed to parse finish timestamp value %s", value);
65878a
         else {
65878a
                 t->realtime = a;
65878a
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
65878a
index d9de46d..b3cb04b 100644
65878a
--- a/src/udev/udev-builtin-net_id.c
65878a
+++ b/src/udev/udev-builtin-net_id.c
65878a
@@ -170,23 +170,17 @@ out:
65878a
 
65878a
 static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
65878a
         struct udev *udev = udev_device_get_udev(names->pcidev);
65878a
-        unsigned int domain;
65878a
-        unsigned int bus;
65878a
-        unsigned int slot;
65878a
-        unsigned int func;
65878a
-        unsigned int dev_id = 0;
65878a
+        unsigned domain, bus, slot, func, dev_id = 0;
65878a
         size_t l;
65878a
         char *s;
65878a
         const char *attr;
65878a
         struct udev_device *pci = NULL;
65878a
-        char slots[256];
65878a
-        DIR *dir;
65878a
+        char slots[256], str[256];
65878a
+        _cleanup_closedir_ DIR *dir = NULL;
65878a
         struct dirent *dent;
65878a
-        char str[256];
65878a
-        int hotplug_slot = 0;
65878a
-        int err = 0;
65878a
+        int hotplug_slot = 0, err = 0;
65878a
 
65878a
-        if (sscanf(udev_device_get_sysname(names->pcidev), "%x:%x:%x.%d", &domain, &bus, &slot, &func) != 4)
65878a
+        if (sscanf(udev_device_get_sysname(names->pcidev), "%x:%x:%x.%u", &domain, &bus, &slot, &func) != 4)
65878a
                 return -ENOENT;
65878a
 
65878a
         /* kernel provided multi-device index */
65878a
@@ -243,7 +237,6 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
65878a
                 if (hotplug_slot > 0)
65878a
                         break;
65878a
         }
65878a
-        closedir(dir);
65878a
 
65878a
         if (hotplug_slot > 0) {
65878a
                 s = names->pci_slot;
65878a
@@ -345,11 +338,11 @@ static int names_bcma(struct udev_device *dev, struct netnames *names) {
65878a
                 return -ENOENT;
65878a
 
65878a
         /* bus num:core num */
65878a
-        if (sscanf(udev_device_get_sysname(bcmadev), "bcma%*d:%d", &core) != 1)
65878a
+        if (sscanf(udev_device_get_sysname(bcmadev), "bcma%*u:%u", &core) != 1)
65878a
                 return -EINVAL;
65878a
         /* suppress the common core == 0 */
65878a
         if (core > 0)
65878a
-                snprintf(names->bcma_core, sizeof(names->bcma_core), "b%d", core);
65878a
+                snprintf(names->bcma_core, sizeof(names->bcma_core), "b%u", core);
65878a
 
65878a
         names->type = NET_BCMA;
65878a
         return 0;