]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(dracut-install): resolve -Wextra warnings
authorJo Zzsi <jozzsicsataban@gmail.com>
Sat, 17 Aug 2024 11:12:46 +0000 (07:12 -0400)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Mon, 19 Aug 2024 10:25:07 +0000 (06:25 -0400)
Explicitly convert from int type to size_t type to resolve
'comparison of integer expressions of different signedness'
warning.

src/install/dracut-install.c

index c2d5a166cc062ff3d3a8181d9da87ccfd7d210ed..f5ddeecf395e52b2ae6ad2c4bbea4c8699c35cdf 100644 (file)
@@ -1569,8 +1569,8 @@ static int find_kmod_module_from_sysfs_driver(struct kmod_ctx *ctx, const char *
 {
         char mod_path[PATH_MAX], mod_realpath[PATH_MAX];
         const char *mod_name;
-        if (snprintf(mod_path, sizeof(mod_path), "%.*s/driver/module",
-                     sysfs_node_len, sysfs_node) >= sizeof(mod_path))
+        if ((size_t)snprintf(mod_path, sizeof(mod_path), "%.*s/driver/module",
+                             sysfs_node_len, sysfs_node) >= sizeof(mod_path))
                 return -1;
 
         if (realpath(mod_path, mod_realpath) == NULL)
@@ -1586,8 +1586,8 @@ static int find_kmod_module_from_sysfs_modalias(struct kmod_ctx *ctx, const char
                                                 struct kmod_list **modules)
 {
         char modalias_path[PATH_MAX];
-        if (snprintf(modalias_path, sizeof(modalias_path), "%.*s/modalias", sysfs_node_len,
-                     sysfs_node) >= sizeof(modalias_path))
+        if ((size_t)snprintf(modalias_path, sizeof(modalias_path), "%.*s/modalias", sysfs_node_len,
+                             sysfs_node) >= sizeof(modalias_path))
                 return -1;
 
         _cleanup_close_ int modalias_file = -1;
@@ -1657,8 +1657,8 @@ static void find_suppliers_for_sys_node(struct kmod_ctx *ctx, Hashmap *suppliers
                         size_t real_path_len = strlen(real_path);
                         while ((dir = readdir(d)) != NULL) {
                                 if (strstr(dir->d_name, "supplier:platform") != NULL) {
-                                        if (snprintf(real_path + real_path_len, sizeof(real_path) - real_path_len, "/%s/supplier",
-                                                     dir->d_name) < sizeof(real_path) - real_path_len) {
+                                        if ((size_t)snprintf(real_path + real_path_len, sizeof(real_path) - real_path_len, "/%s/supplier",
+                                                             dir->d_name) < sizeof(real_path) - real_path_len) {
                                                 char *real_supplier_path = realpath(real_path, NULL);
                                                 if (real_supplier_path != NULL)
                                                         if (hashmap_put(suppliers, real_supplier_path, real_supplier_path) < 0)
@@ -1668,7 +1668,7 @@ static void find_suppliers_for_sys_node(struct kmod_ctx *ctx, Hashmap *suppliers
                         }
                         closedir(d);
                 }
-                strncat(node_path, "/..", 3); // Also find suppliers of parents
+                strcat(node_path, "/.."); // Also find suppliers of parents
         }
 }