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 @@
1818
 /* Internal helper functions */
1919
 static int execute_git_command(const char *args, char *output, size_t output_size);
2020
 static int validate_git_installation(void);
21
-static int detect_repository_scope(git_scope_t *detected_scope);
2221
 static bool is_valid_git_config_value(const char *value);
2322
 static int backup_git_config_if_needed(git_scope_t scope);
24
-static int restore_git_config_if_needed(git_scope_t scope);
2523
 
2624
 /* Initialize git operations */
2725
 int git_ops_init(void) {
@@ -476,9 +474,9 @@ int git_configure_ssh(const account_t *account, git_scope_t scope) {
476474
     }
477475
     
478476
     /* Build SSH command with security options */
479
-    if (snprintf(ssh_command, sizeof(ssh_command),
480
-                 "ssh -i '%s' -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no",
481
-                 expanded_key_path) >= sizeof(ssh_command)) {
477
+    if ((size_t)snprintf(ssh_command, sizeof(ssh_command),
478
+                        "ssh -i '%s' -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no",
479
+                        expanded_key_path) >= sizeof(ssh_command)) {
482480
         set_error(ERR_INVALID_ARGS, "SSH command too long");
483481
         return -1;
484482
     }
@@ -628,20 +626,6 @@ static int validate_git_installation(void) {
628626
     return 0;
629627
 }
630628
 
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
-}
645629
 
646630
 /* Validate git config value for security */
647631
 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) {
674658
     return 0;
675659
 }
676660
 
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)
227227
     }
228228
     
229229
     /* Build ssh-agent command with socket path */
230
-    if (snprintf(command, sizeof(command), 
231
-                 "ssh-agent -a '%s/ssh-agent.%s.sock'", 
232
-                 socket_dir, account->name) >= sizeof(command)) {
230
+    if ((size_t)snprintf(command, sizeof(command), 
231
+                        "ssh-agent -a '%s/ssh-agent.%s.sock'", 
232
+                        socket_dir, account->name) >= sizeof(command)) {
233233
         set_error(ERR_INVALID_ARGS, "SSH agent command too long");
234234
         return -1;
235235
     }
@@ -359,7 +359,7 @@ int ssh_add_key(ssh_config_t *ssh_config, const char *key_path) {
359359
     }
360360
     
361361
     /* 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)) {
363363
         set_error(ERR_INVALID_ARGS, "SSH add command too long");
364364
         return -1;
365365
     }
@@ -483,7 +483,7 @@ int ssh_configure_host_alias(const account_t *account) {
483483
     log_debug("Configuring SSH host alias: %s", account->ssh_host_alias);
484484
     
485485
     /* 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)) {
487487
         set_error(ERR_INVALID_PATH, "SSH config directory path too long");
488488
         return -1;
489489
     }
@@ -496,7 +496,7 @@ int ssh_configure_host_alias(const account_t *account) {
496496
     }
497497
     
498498
     /* 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)) {
500500
         set_error(ERR_INVALID_PATH, "SSH config file path too long");
501501
         return -1;
502502
     }
@@ -547,9 +547,9 @@ int ssh_test_connection(const account_t *account, const char *host) {
547547
     /* Build SSH test command */
548548
     if (strlen(account->ssh_host_alias) > 0) {
549549
         /* Use host alias */
550
-        if (snprintf(command, sizeof(command), 
551
-                     "ssh -o ConnectTimeout=5 -o BatchMode=yes %s echo 'SSH connection test successful'",
552
-                     account->ssh_host_alias) >= sizeof(command)) {
550
+        if ((size_t)snprintf(command, sizeof(command), 
551
+                            "ssh -o ConnectTimeout=5 -o BatchMode=yes %s echo 'SSH connection test successful'",
552
+                            account->ssh_host_alias) >= sizeof(command)) {
553553
             set_error(ERR_INVALID_ARGS, "SSH test command too long");
554554
             return -1;
555555
         }
@@ -560,9 +560,9 @@ int ssh_test_connection(const account_t *account, const char *host) {
560560
             return -1;
561561
         }
562562
         
563
-        if (snprintf(command, sizeof(command),
564
-                     "ssh -o ConnectTimeout=5 -o BatchMode=yes -i '%s' %s echo 'SSH connection test successful'",
565
-                     expanded_key_path, host) >= 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'",
565
+                            expanded_key_path, host) >= sizeof(command)) {
566566
             set_error(ERR_INVALID_ARGS, "SSH test command too long");
567567
             return -1;
568568
         }
@@ -663,12 +663,12 @@ static int create_isolated_agent_socket_dir(char *socket_dir, size_t socket_dir_
663663
     
664664
     /* Prefer XDG_RUNTIME_DIR if available */
665665
     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) {
667667
             set_error(ERR_INVALID_PATH, "Socket directory path too long");
668668
             return -1;
669669
         }
670670
     } 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) {
672672
             set_error(ERR_INVALID_PATH, "Socket directory path too long");
673673
             return -1;
674674
         }