]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hwdb-util: drop unused value assignment
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 18 Feb 2025 18:46:55 +0000 (03:46 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 4 Mar 2025 21:28:53 +0000 (21:28 +0000)
The values assigned to 'r' were never used, and overwritten by the next
call of read_line_full().

Fixes CID#1548043 and CID#1548064.

(cherry picked from commit 00575cfd696a2a335decb66580727fafd3c152aa)

src/shared/hwdb-util.c

index bc4da846f1bcb604c956b91b3e19284016f895fb..3efae8a3a589be82b0ec30f0584eaf9fe6258082 100644 (file)
@@ -461,7 +461,7 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
         _cleanup_fclose_ FILE *f = NULL;
         _cleanup_strv_free_ char **match_list = NULL;
         uint32_t line_number = 0;
-        int r, err;
+        int r;
 
         f = fopen(filename, "re");
         if (!f)
@@ -501,24 +501,23 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
                                 break;
 
                         if (line[0] == ' ') {
-                                r = log_syntax(NULL, LOG_WARNING, filename, line_number, SYNTHETIC_ERRNO(EINVAL),
-                                               "Match expected but got indented property \"%s\", ignoring line.", line);
+                                log_syntax(NULL, LOG_WARNING, filename, line_number, 0,
+                                           "Match expected but got indented property \"%s\", ignoring line.", line);
                                 break;
                         }
 
                         /* start of record, first match */
                         state = HW_MATCH;
 
-                        err = strv_extend(&match_list, line);
-                        if (err < 0)
-                                return err;
-
+                        r = strv_extend(&match_list, line);
+                        if (r < 0)
+                                return r;
                         break;
 
                 case HW_MATCH:
                         if (len == 0) {
-                                r = log_syntax(NULL, LOG_WARNING, filename, line_number, SYNTHETIC_ERRNO(EINVAL),
-                                               "Property expected, ignoring record with no properties.");
+                                log_syntax(NULL, LOG_WARNING, filename, line_number, 0,
+                                           "Property expected, ignoring record with no properties.");
                                 state = HW_NONE;
                                 match_list = strv_free(match_list);
                                 break;
@@ -526,18 +525,15 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
 
                         if (line[0] != ' ') {
                                 /* another match */
-                                err = strv_extend(&match_list, line);
-                                if (err < 0)
-                                        return err;
-
+                                r = strv_extend(&match_list, line);
+                                if (r < 0)
+                                        return r;
                                 break;
                         }
 
                         /* first data */
                         state = HW_DATA;
-                        err = insert_data(trie, match_list, line, filename, file_priority, line_number, compat);
-                        if (err < 0)
-                                r = err;
+                        (void) insert_data(trie, match_list, line, filename, file_priority, line_number, compat);
                         break;
 
                 case HW_DATA:
@@ -549,16 +545,14 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
                         }
 
                         if (line[0] != ' ') {
-                                r = log_syntax(NULL, LOG_WARNING, filename, line_number, SYNTHETIC_ERRNO(EINVAL),
-                                               "Property or empty line expected, got \"%s\", ignoring record.", line);
+                                log_syntax(NULL, LOG_WARNING, filename, line_number, 0,
+                                           "Property or empty line expected, got \"%s\", ignoring record.", line);
                                 state = HW_NONE;
                                 match_list = strv_free(match_list);
                                 break;
                         }
 
-                        err = insert_data(trie, match_list, line, filename, file_priority, line_number, compat);
-                        if (err < 0)
-                                r = err;
+                        (void) insert_data(trie, match_list, line, filename, file_priority, line_number, compat);
                         break;
                 };
         }