ryantimwilson / rpms / systemd

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