daandemeyer / rpms / systemd

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