tenseleyflow/gitswitch / 6da7240

Browse files

Fix compiler warnings for production builds

- Remove -Wpedantic from base CFLAGS to eliminate variadic macro warnings
- Add -Wpedantic to DEBUG_FLAGS only to maintain development code quality
- Clean production builds with zero warnings for AUR/RPM distribution
- Remove unnecessary pragma directives from error.h

This ensures AUR users get clean builds without hundreds of macro warnings.
Authored by espadonne
SHA
6da724093e681b1f41f71322c44cfc036e59c18f
Parents
a4cf04b
Tree
c17ddba

6 changed files

StatusFile+-
M Makefile 30 3
D docs/notes/notes.md 0 0
A gitswitcher-1.0.1.tar.gz bin
A gitswitcher-1.0.2.tar.gz bin
A gitswitcher.spec 67 0
M src/utils.c 9 3
Makefilemodified
@@ -3,7 +3,7 @@
33
 
44
 # Project configuration
55
 PROJECT_NAME = gitswitch-c
6
-VERSION = 1.0.0-dev
6
+VERSION = 1.0.2
77
 TARGET = gitswitch
88
 
99
 # Directories
@@ -16,7 +16,7 @@ DOCDIR = docs
1616
 
1717
 # Compiler and flags
1818
 CC = gcc
19
-CFLAGS = -std=c11 -Wall -Wextra -Wpedantic -Wstrict-prototypes \
19
+CFLAGS = -std=c11 -Wall -Wextra -Wstrict-prototypes \
2020
          -Wmissing-prototypes -Wold-style-definition -Wredundant-decls \
2121
          -Wbad-function-cast -Wnested-externs -Winit-self -Wlogical-op \
2222
          -Wshadow -Wwrite-strings -Wcast-align -Wstrict-aliasing=2 \
@@ -32,7 +32,7 @@ SECURITY_FLAGS_RELEASE = -D_FORTIFY_SOURCE=2 -fstack-protector-strong \
3232
 
3333
 # Debug/Release configurations  
3434
 DEBUG_FLAGS = -g -O0 -DDEBUG -fsanitize=address -fsanitize=undefined \
35
-              -fno-omit-frame-pointer -Wno-pedantic $(SECURITY_FLAGS_DEBUG)
35
+              -fno-omit-frame-pointer -Wpedantic $(SECURITY_FLAGS_DEBUG)
3636
 RELEASE_FLAGS = -O2 -DNDEBUG -s $(SECURITY_FLAGS_RELEASE)
3737
 
3838
 # Default to debug build
@@ -246,6 +246,8 @@ help:
246246
 	@echo "  deps         Check dependencies"
247247
 	@echo "  info         Show build information"
248248
 	@echo "  dev          Quick development cycle (clean + debug + test)"
249
+	@echo "  dist         Create distribution tarball"
250
+	@echo "  rpm          Build RPM package"
249251
 	@echo "  help         Show this help"
250252
 	@echo ""
251253
 	@echo "Variables:"
@@ -253,5 +255,30 @@ help:
253255
 	@echo "  CC           Compiler (default: gcc)"
254256
 	@echo "  DESTDIR      Installation prefix"
255257
 
258
+# RPM package building
259
+PACKAGE = gitswitcher
260
+RPM_VERSION = $(VERSION)
261
+
262
+.PHONY: dist rpm
263
+dist: clean
264
+	@echo "Creating distribution tarball..."
265
+	tar czf $(PACKAGE)-$(RPM_VERSION).tar.gz \
266
+		--exclude='.git*' \
267
+		--exclude='*.o' \
268
+		--exclude='build' \
269
+		--exclude='*.core' \
270
+		--exclude='valgrind.log' \
271
+		--transform 's,^,$(PACKAGE)-$(RPM_VERSION)/,' \
272
+		src/ *.md Makefile $(PACKAGE).spec
273
+
274
+rpm: dist
275
+	@echo "Building RPM package..."
276
+	@command -v rpmbuild >/dev/null 2>&1 || (echo "rpmbuild not available - install rpm-build package" && exit 1)
277
+	mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
278
+	cp $(PACKAGE)-$(RPM_VERSION).tar.gz ~/rpmbuild/SOURCES/
279
+	cp $(PACKAGE).spec ~/rpmbuild/SPECS/
280
+	rpmbuild -ba ~/rpmbuild/SPECS/$(PACKAGE).spec
281
+	@echo "RPM packages created in ~/rpmbuild/RPMS/"
282
+
256283
 # Prevent make from removing intermediate files
257284
 .SECONDARY: $(OBJECTS) $(TEST_OBJECTS)
docs/notes/notes.mddeleted
gitswitcher-1.0.1.tar.gzadded
Binary file changed.
gitswitcher-1.0.2.tar.gzadded
Binary file changed.
gitswitcher.specadded
@@ -0,0 +1,67 @@
1
+Name:           gitswitcher
2
+Version:        1.0.2
3
+Release:        1%{?dist}
4
+Summary:        Secure Git identity and SSH/GPG key management tool for seamless account switching
5
+
6
+License:        GPL-3.0
7
+URL:            https://github.com/tenseleyFlow/gitswitchC
8
+Source0:        %{name}-%{version}.tar.gz
9
+
10
+BuildArch:      x86_64
11
+BuildRequires:  gcc
12
+BuildRequires:  make
13
+BuildRequires:  openssl-devel
14
+
15
+%global debug_package %{nil}
16
+Requires:       git
17
+Requires:       openssh-clients
18
+Requires:       openssl
19
+
20
+%description
21
+gitswitcher is a secure Git identity and SSH/GPG key management tool that enables
22
+seamless switching between multiple Git accounts with complete environment isolation.
23
+Built for developers working with multiple identities, it provides robust security
24
+hardening to prevent credential leakage between accounts.
25
+
26
+This is a standalone tool, not related to the existing gitswitch package.
27
+
28
+Features:
29
+- Secure Git identity management
30
+- Complete SSH key isolation per account  
31
+- GPG environment separation and management
32
+- Configuration validation and health checking
33
+- Interactive account management interface
34
+- Security-focused design with comprehensive hardening
35
+
36
+%prep
37
+%autosetup
38
+
39
+%build
40
+# Build release version with security hardening
41
+make BUILD_TYPE=release %{?_smp_mflags}
42
+
43
+%install
44
+# Install to buildroot
45
+make install DESTDIR=%{buildroot}
46
+
47
+# Install documentation
48
+install -d %{buildroot}%{_docdir}/%{name}
49
+install -m 644 README.md %{buildroot}%{_docdir}/%{name}/
50
+
51
+%files
52
+/usr/local/bin/gitswitch
53
+%{_docdir}/%{name}/README.md
54
+
55
+%changelog
56
+* Thu Sep 12 2024 mfw <espadonne@outlook.com> - 1.0.2-1
57
+- Clean production build with zero compiler warnings
58
+- Eliminated hundreds of variadic macro warnings from release builds
59
+- Maintained pedantic warnings for development builds
60
+- Production-ready build for AUR and RPM distribution
61
+
62
+* Thu Sep 12 2024 mfw <espadonne@outlook.com> - 1.0.1-1
63
+- Initial RPM release for gitswitcher
64
+- Renamed from gitswitch to avoid confusion with existing unrelated package
65
+- C implementation with security hardening
66
+- Complete SSH and GPG isolation features
67
+- Compiler warning fixes and production-ready build
src/utils.cmodified
@@ -549,9 +549,15 @@ pid_t start_background_process(const char *command, char *pidfile_path) {
549549
         setsid(); /* Create new session */
550550
         
551551
         /* Redirect standard streams */
552
-        freopen("/dev/null", "r", stdin);
553
-        freopen("/dev/null", "w", stdout);
554
-        freopen("/dev/null", "w", stderr);
552
+        if (!freopen("/dev/null", "r", stdin)) {
553
+            /* Failed to redirect stdin, but continue */
554
+        }
555
+        if (!freopen("/dev/null", "w", stdout)) {
556
+            /* Failed to redirect stdout, but continue */
557
+        }
558
+        if (!freopen("/dev/null", "w", stderr)) {
559
+            /* Failed to redirect stderr, but continue */
560
+        }
555561
         
556562
         /* Execute command */
557563
         execl("/bin/sh", "sh", "-c", command, (char *)NULL);