tenseleyflow/gitswitch / 5be3df3

Browse files

fix: resolve compiler warnings for clean NixOS builds

- Change -std=c11 to -std=gnu11 to support ##__VA_ARGS__ extension
- Add -Wp,-U_FORTIFY_SOURCE to debug builds to prevent glibc warning
- Remove unused function remove_existing_account_sections from config.c
Authored by espadonne
SHA
5be3df3d7862b5ef0b7bbf064a322bb9cda217cf
Parents
cdf6178
Tree
b54b70d

2 changed files

StatusFile+-
M Makefile 3 3
M src/config.c 0 29
Makefilemodified
@@ -19,7 +19,7 @@ UNAME_S := $(shell uname -s)
1919
 
2020
 # Compiler and flags
2121
 CC = gcc
22
-CFLAGS = -std=c11 -Wall -Wextra -Wstrict-prototypes \
22
+CFLAGS = -std=gnu11 -Wall -Wextra -Wstrict-prototypes \
2323
          -Wmissing-prototypes -Wold-style-definition -Wredundant-decls \
2424
          -Wbad-function-cast -Wnested-externs -Winit-self \
2525
          -Wshadow -Wwrite-strings -Wcast-align -Wstrict-aliasing=2 \
@@ -50,8 +50,8 @@ ifeq ($(UNAME_S),Darwin)
5050
     endif
5151
 endif
5252
 
53
-# Debug/Release configurations  
54
-DEBUG_FLAGS = -g -O0 -DDEBUG -fsanitize=address -fsanitize=undefined \
53
+# Debug/Release configurations
54
+DEBUG_FLAGS = -g -O0 -DDEBUG -Wp,-U_FORTIFY_SOURCE -fsanitize=address -fsanitize=undefined \
5555
               -fno-omit-frame-pointer -Wpedantic $(SECURITY_FLAGS_DEBUG)
5656
 RELEASE_FLAGS = -O2 -DNDEBUG -s $(SECURITY_FLAGS_RELEASE)
5757
 
src/config.cmodified
@@ -57,7 +57,6 @@ static int validate_config_file_security(const char *config_path);
5757
 static int create_config_directory_secure(const char *config_dir);
5858
 static int load_accounts_from_toml(gitswitch_ctx_t *ctx, const toml_document_t *doc);
5959
 static int save_accounts_to_toml(const gitswitch_ctx_t *ctx, toml_document_t *doc);
60
-static int remove_existing_account_sections(toml_document_t *doc);
6160
 static int parse_account_id_from_section(const char *section_name, uint32_t *account_id);
6261
 static int validate_account_security(const account_t *account);
6362
 
@@ -773,34 +772,6 @@ static int validate_account_security(const account_t *account) {
773772
     return 0;
774773
 }
775774
 
776
-/* Remove all existing account sections from TOML document */
777
-static int remove_existing_account_sections(toml_document_t *doc) {
778
-    size_t i = 0;
779
-    
780
-    if (!doc) {
781
-        set_error(ERR_INVALID_ARGS, "Invalid arguments to remove_existing_account_sections");
782
-        return -1;
783
-    }
784
-    
785
-    /* Iterate through sections and remove account sections */
786
-    while (i < doc->section_count) {
787
-        if (string_starts_with(doc->sections[i].name, "accounts.")) {
788
-            log_debug("Removing existing account section: %s", doc->sections[i].name);
789
-            
790
-            /* Shift remaining sections down */
791
-            for (size_t j = i; j < doc->section_count - 1; j++) {
792
-                doc->sections[j] = doc->sections[j + 1];
793
-            }
794
-            doc->section_count--;
795
-            /* Don't increment i since we shifted sections down */
796
-        } else {
797
-            i++;
798
-        }
799
-    }
800
-    
801
-    return 0;
802
-}
803
-
804775
 /* Save accounts to TOML document */
805776
 static int save_accounts_to_toml(const gitswitch_ctx_t *ctx, toml_document_t *doc) {
806777
     char section_name[64];