tenseleyflow/gitswitch / 5d5a0ca

Browse files

no warnings

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
5d5a0caf31e2125a03cc587d781b383ed663c6c9
Parents
124612d
Tree
9e635ee

2 changed files

StatusFile+-
M src/git_ops.c 3 25
M src/ssh_manager.c 14 14
src/git_ops.cmodified
@@ -18,10 +18,8 @@
18
 /* Internal helper functions */
18
 /* Internal helper functions */
19
 static int execute_git_command(const char *args, char *output, size_t output_size);
19
 static int execute_git_command(const char *args, char *output, size_t output_size);
20
 static int validate_git_installation(void);
20
 static int validate_git_installation(void);
21
-static int detect_repository_scope(git_scope_t *detected_scope);
22
 static bool is_valid_git_config_value(const char *value);
21
 static bool is_valid_git_config_value(const char *value);
23
 static int backup_git_config_if_needed(git_scope_t scope);
22
 static int backup_git_config_if_needed(git_scope_t scope);
24
-static int restore_git_config_if_needed(git_scope_t scope);
25
 
23
 
26
 /* Initialize git operations */
24
 /* Initialize git operations */
27
 int git_ops_init(void) {
25
 int git_ops_init(void) {
@@ -476,9 +474,9 @@ int git_configure_ssh(const account_t *account, git_scope_t scope) {
476
     }
474
     }
477
     
475
     
478
     /* Build SSH command with security options */
476
     /* Build SSH command with security options */
479
-    if (snprintf(ssh_command, sizeof(ssh_command),
477
+    if ((size_t)snprintf(ssh_command, sizeof(ssh_command),
480
-                 "ssh -i '%s' -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no",
478
+                        "ssh -i '%s' -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no",
481
-                 expanded_key_path) >= sizeof(ssh_command)) {
479
+                        expanded_key_path) >= sizeof(ssh_command)) {
482
         set_error(ERR_INVALID_ARGS, "SSH command too long");
480
         set_error(ERR_INVALID_ARGS, "SSH command too long");
483
         return -1;
481
         return -1;
484
     }
482
     }
@@ -628,20 +626,6 @@ static int validate_git_installation(void) {
628
     return 0;
626
     return 0;
629
 }
627
 }
630
 
628
 
631
-/* Detect repository scope */
632
-static int detect_repository_scope(git_scope_t *detected_scope) {
633
-    if (!detected_scope) {
634
-        return -1;
635
-    }
636
-    
637
-    if (git_is_repository()) {
638
-        *detected_scope = GIT_SCOPE_LOCAL;
639
-    } else {
640
-        *detected_scope = GIT_SCOPE_GLOBAL;
641
-    }
642
-    
643
-    return 0;
644
-}
645
 
629
 
646
 /* Validate git config value for security */
630
 /* Validate git config value for security */
647
 static bool is_valid_git_config_value(const char *value) {
631
 static bool is_valid_git_config_value(const char *value) {
@@ -674,9 +658,3 @@ static int backup_git_config_if_needed(git_scope_t scope) {
674
     return 0;
658
     return 0;
675
 }
659
 }
676
 
660
 
677
-/* Restore git config if needed */
678
-static int restore_git_config_if_needed(git_scope_t scope) {
679
-    /* TODO: Implement config restore */
680
-    (void)scope; /* Suppress unused parameter warning */
681
-    return 0;
682
-}
src/ssh_manager.cmodified
@@ -227,9 +227,9 @@ int ssh_start_isolated_agent(ssh_config_t *ssh_config, const account_t *account)
227
     }
227
     }
228
     
228
     
229
     /* Build ssh-agent command with socket path */
229
     /* Build ssh-agent command with socket path */
230
-    if (snprintf(command, sizeof(command), 
230
+    if ((size_t)snprintf(command, sizeof(command), 
231
-                 "ssh-agent -a '%s/ssh-agent.%s.sock'", 
231
+                        "ssh-agent -a '%s/ssh-agent.%s.sock'", 
232
-                 socket_dir, account->name) >= sizeof(command)) {
232
+                        socket_dir, account->name) >= sizeof(command)) {
233
         set_error(ERR_INVALID_ARGS, "SSH agent command too long");
233
         set_error(ERR_INVALID_ARGS, "SSH agent command too long");
234
         return -1;
234
         return -1;
235
     }
235
     }
@@ -359,7 +359,7 @@ int ssh_add_key(ssh_config_t *ssh_config, const char *key_path) {
359
     }
359
     }
360
     
360
     
361
     /* Build ssh-add command */
361
     /* Build ssh-add command */
362
-    if (snprintf(command, sizeof(command), "ssh-add '%s'", key_path) >= sizeof(command)) {
362
+    if ((size_t)snprintf(command, sizeof(command), "ssh-add '%s'", key_path) >= sizeof(command)) {
363
         set_error(ERR_INVALID_ARGS, "SSH add command too long");
363
         set_error(ERR_INVALID_ARGS, "SSH add command too long");
364
         return -1;
364
         return -1;
365
     }
365
     }
@@ -483,7 +483,7 @@ int ssh_configure_host_alias(const account_t *account) {
483
     log_debug("Configuring SSH host alias: %s", account->ssh_host_alias);
483
     log_debug("Configuring SSH host alias: %s", account->ssh_host_alias);
484
     
484
     
485
     /* Get SSH config directory */
485
     /* Get SSH config directory */
486
-    if (snprintf(ssh_config_dir, sizeof(ssh_config_dir), "%s/.ssh", getenv("HOME")) >= sizeof(ssh_config_dir)) {
486
+    if ((size_t)snprintf(ssh_config_dir, sizeof(ssh_config_dir), "%s/.ssh", getenv("HOME")) >= sizeof(ssh_config_dir)) {
487
         set_error(ERR_INVALID_PATH, "SSH config directory path too long");
487
         set_error(ERR_INVALID_PATH, "SSH config directory path too long");
488
         return -1;
488
         return -1;
489
     }
489
     }
@@ -496,7 +496,7 @@ int ssh_configure_host_alias(const account_t *account) {
496
     }
496
     }
497
     
497
     
498
     /* SSH config file path */
498
     /* SSH config file path */
499
-    if (snprintf(ssh_config_path, sizeof(ssh_config_path), "%s/config", ssh_config_dir) >= sizeof(ssh_config_path)) {
499
+    if ((size_t)snprintf(ssh_config_path, sizeof(ssh_config_path), "%s/config", ssh_config_dir) >= sizeof(ssh_config_path)) {
500
         set_error(ERR_INVALID_PATH, "SSH config file path too long");
500
         set_error(ERR_INVALID_PATH, "SSH config file path too long");
501
         return -1;
501
         return -1;
502
     }
502
     }
@@ -547,9 +547,9 @@ int ssh_test_connection(const account_t *account, const char *host) {
547
     /* Build SSH test command */
547
     /* Build SSH test command */
548
     if (strlen(account->ssh_host_alias) > 0) {
548
     if (strlen(account->ssh_host_alias) > 0) {
549
         /* Use host alias */
549
         /* Use host alias */
550
-        if (snprintf(command, sizeof(command), 
550
+        if ((size_t)snprintf(command, sizeof(command), 
551
-                     "ssh -o ConnectTimeout=5 -o BatchMode=yes %s echo 'SSH connection test successful'",
551
+                            "ssh -o ConnectTimeout=5 -o BatchMode=yes %s echo 'SSH connection test successful'",
552
-                     account->ssh_host_alias) >= sizeof(command)) {
552
+                            account->ssh_host_alias) >= sizeof(command)) {
553
             set_error(ERR_INVALID_ARGS, "SSH test command too long");
553
             set_error(ERR_INVALID_ARGS, "SSH test command too long");
554
             return -1;
554
             return -1;
555
         }
555
         }
@@ -560,9 +560,9 @@ int ssh_test_connection(const account_t *account, const char *host) {
560
             return -1;
560
             return -1;
561
         }
561
         }
562
         
562
         
563
-        if (snprintf(command, sizeof(command),
563
+        if ((size_t)snprintf(command, sizeof(command),
564
-                     "ssh -o ConnectTimeout=5 -o BatchMode=yes -i '%s' %s echo 'SSH connection test successful'",
564
+                            "ssh -o ConnectTimeout=5 -o BatchMode=yes -i '%s' %s echo 'SSH connection test successful'",
565
-                     expanded_key_path, host) >= sizeof(command)) {
565
+                            expanded_key_path, host) >= sizeof(command)) {
566
             set_error(ERR_INVALID_ARGS, "SSH test command too long");
566
             set_error(ERR_INVALID_ARGS, "SSH test command too long");
567
             return -1;
567
             return -1;
568
         }
568
         }
@@ -663,12 +663,12 @@ static int create_isolated_agent_socket_dir(char *socket_dir, size_t socket_dir_
663
     
663
     
664
     /* Prefer XDG_RUNTIME_DIR if available */
664
     /* Prefer XDG_RUNTIME_DIR if available */
665
     if (runtime_dir && path_exists(runtime_dir)) {
665
     if (runtime_dir && path_exists(runtime_dir)) {
666
-        if (snprintf(socket_dir, socket_dir_size, "%s/gitswitch-ssh", runtime_dir) >= socket_dir_size) {
666
+        if ((size_t)snprintf(socket_dir, socket_dir_size, "%s/gitswitch-ssh", runtime_dir) >= socket_dir_size) {
667
             set_error(ERR_INVALID_PATH, "Socket directory path too long");
667
             set_error(ERR_INVALID_PATH, "Socket directory path too long");
668
             return -1;
668
             return -1;
669
         }
669
         }
670
     } else {
670
     } else {
671
-        if (snprintf(socket_dir, socket_dir_size, "%s/gitswitch-ssh-%d", tmp_dir, getuid()) >= socket_dir_size) {
671
+        if ((size_t)snprintf(socket_dir, socket_dir_size, "%s/gitswitch-ssh-%d", tmp_dir, getuid()) >= socket_dir_size) {
672
             set_error(ERR_INVALID_PATH, "Socket directory path too long");
672
             set_error(ERR_INVALID_PATH, "Socket directory path too long");
673
             return -1;
673
             return -1;
674
         }
674
         }