tenseleyflow/gitswitch / 124612d

Browse files

more warnings

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
124612d5030a2191fe4dc2e8b486c0f52ae6a716
Parents
57c2bc7
Tree
e36ddfa

4 changed files

StatusFile+-
M src/accounts.c 2 2
M src/config.c 4 4
M src/git_ops.c 7 7
M src/utils.c 5 5
src/accounts.cmodified
@@ -762,8 +762,8 @@ static int validate_gpg_key_availability(const char *gpg_key_id) {
762762
     }
763763
     
764764
     /* Try to find the key in the GPG keyring */
765
-    if (SAFE_SNPRINTF(command, sizeof(command), "gpg --list-secret-keys %s >/dev/null 2>&1", 
766
-                     gpg_key_id) != 0) {
765
+    if ((size_t)snprintf(command, sizeof(command), "gpg --list-secret-keys %s >/dev/null 2>&1", 
766
+                        gpg_key_id) >= sizeof(command)) {
767767
         log_error("GPG command too long");
768768
         return -1;
769769
     }
src/config.cmodified
@@ -171,7 +171,7 @@ int config_save(const gitswitch_ctx_t *ctx, const char *config_path) {
171171
     }
172172
     
173173
     /* Create temporary file path for atomic write */
174
-    if (SAFE_SNPRINTF(temp_path, sizeof(temp_path), "%s.tmp", config_path) != 0) {
174
+    if ((size_t)snprintf(temp_path, sizeof(temp_path), "%s.tmp", config_path) >= sizeof(temp_path)) {
175175
         set_error(ERR_INVALID_ARGS, "Temporary file path too long");
176176
         return -1;
177177
     }
@@ -504,8 +504,8 @@ int config_backup(const char *config_path) {
504504
     }
505505
     
506506
     /* Create backup path */
507
-    if (SAFE_SNPRINTF(backup_path, sizeof(backup_path), "%s.backup.%s", 
508
-                     config_path, timestamp) != 0) {
507
+    if ((size_t)snprintf(backup_path, sizeof(backup_path), "%s.backup.%s", 
508
+                        config_path, timestamp) >= sizeof(backup_path)) {
509509
         set_error(ERR_INVALID_ARGS, "Backup path too long");
510510
         return -1;
511511
     }
@@ -773,7 +773,7 @@ static int save_accounts_to_toml(const gitswitch_ctx_t *ctx, toml_document_t *do
773773
         const account_t *account = &ctx->accounts[i];
774774
         
775775
         /* Create section name */
776
-        if (SAFE_SNPRINTF(section_name, sizeof(section_name), "accounts.%u", account->id) != 0) {
776
+        if ((size_t)snprintf(section_name, sizeof(section_name), "accounts.%u", account->id) >= sizeof(section_name)) {
777777
             set_error(ERR_ACCOUNT_INVALID, "Account ID too large: %u", account->id);
778778
             return -1;
779779
         }
src/git_ops.cmodified
@@ -340,8 +340,8 @@ int git_set_config_value(const char *key, const char *value, git_scope_t scope)
340340
     }
341341
     
342342
     /* Build git config command */
343
-    if (SAFE_SNPRINTF(command, sizeof(command), "config %s '%s' '%s'", 
344
-                     scope_flag, key, value) != 0) {
343
+    if ((size_t)snprintf(command, sizeof(command), "config %s '%s' '%s'", 
344
+                        scope_flag, key, value) >= sizeof(command)) {
345345
         set_error(ERR_INVALID_ARGS, "Git config command too long");
346346
         return -1;
347347
     }
@@ -374,7 +374,7 @@ int git_get_config_value(const char *key, char *value, size_t value_size, git_sc
374374
     }
375375
     
376376
     /* Build git config command */
377
-    if (SAFE_SNPRINTF(command, sizeof(command), "config %s '%s'", scope_flag, key) != 0) {
377
+    if ((size_t)snprintf(command, sizeof(command), "config %s '%s'", scope_flag, key) >= sizeof(command)) {
378378
         set_error(ERR_INVALID_ARGS, "Git config command too long");
379379
         return -1;
380380
     }
@@ -410,8 +410,8 @@ int git_unset_config_value(const char *key, git_scope_t scope) {
410410
     }
411411
     
412412
     /* Build git config unset command */
413
-    if (SAFE_SNPRINTF(command, sizeof(command), "config %s --unset '%s'", 
414
-                     scope_flag, key) != 0) {
413
+    if ((size_t)snprintf(command, sizeof(command), "config %s --unset '%s'", 
414
+                        scope_flag, key) >= sizeof(command)) {
415415
         set_error(ERR_INVALID_ARGS, "Git config command too long");
416416
         return -1;
417417
     }
@@ -441,7 +441,7 @@ int git_list_config(git_scope_t scope, char *output, size_t output_size) {
441441
     }
442442
     
443443
     /* Build git config list command */
444
-    if (SAFE_SNPRINTF(command, sizeof(command), "config %s --list", scope_flag) != 0) {
444
+    if ((size_t)snprintf(command, sizeof(command), "config %s --list", scope_flag) >= sizeof(command)) {
445445
         set_error(ERR_INVALID_ARGS, "Git config command too long");
446446
         return -1;
447447
     }
@@ -571,7 +571,7 @@ static int execute_git_command(const char *args, char *output, size_t output_siz
571571
     }
572572
     
573573
     /* Build full git command */
574
-    if (SAFE_SNPRINTF(command, sizeof(command), "git %s 2>&1", args) != 0) {
574
+    if ((size_t)snprintf(command, sizeof(command), "git %s 2>&1", args) >= sizeof(command)) {
575575
         set_error(ERR_INVALID_ARGS, "Git command too long");
576576
         return -1;
577577
     }
src/utils.cmodified
@@ -223,7 +223,7 @@ int create_directory_recursive(const char *path, mode_t mode) {
223223
     char *p = NULL;
224224
     size_t len;
225225
     
226
-    if (SAFE_SNPRINTF(temp_path, sizeof(temp_path), "%s", path) != 0) {
226
+    if ((size_t)snprintf(temp_path, sizeof(temp_path), "%s", path) >= sizeof(temp_path)) {
227227
         set_error(ERR_INVALID_ARGS, "Path too long");
228228
         return -1;
229229
     }
@@ -406,8 +406,8 @@ int backup_file(const char *file_path, const char *backup_suffix) {
406406
         return -1;
407407
     }
408408
     
409
-    if (SAFE_SNPRINTF(backup_path, sizeof(backup_path), "%s%s", 
410
-                     file_path, backup_suffix) != 0) {
409
+    if ((size_t)snprintf(backup_path, sizeof(backup_path), "%s%s", 
410
+                        file_path, backup_suffix) >= sizeof(backup_path)) {
411411
         set_error(ERR_INVALID_ARGS, "Backup path too long");
412412
         return -1;
413413
     }
@@ -520,8 +520,8 @@ bool command_exists(const char *command) {
520520
     
521521
     if (!command) return false;
522522
     
523
-    if (SAFE_SNPRINTF(test_command, sizeof(test_command), 
524
-                     "command -v %s >/dev/null 2>&1", command) != 0) {
523
+    if ((size_t)snprintf(test_command, sizeof(test_command), 
524
+                        "command -v %s >/dev/null 2>&1", command) >= sizeof(test_command)) {
525525
         return false;
526526
     }
527527