johnmehr / gitup

A minimalist, dependency-free FreeBSD program to clone/pull Git repositories.
BSD 2-Clause "Simplified" License
50 stars 9 forks source link

build warnings: variable set but not used #95

Closed emaste closed 11 months ago

emaste commented 1 year ago
gitup.c:2424:12: warning: variable 'old_file_size' set but not used [-Wunused-but-set-variable]
        uint32_t  old_file_size = 0, new_file_size = 0, new_position = 0;
                  ^
gitup.c:3503:38: warning: variable 'pack_history_exists' set but not used [-Wunused-but-set-variable]
        bool      pack_data_exists = false, pack_history_exists = false;
                                            ^
emaste commented 1 year ago

(at 50f1e8cd428eaa168bfd7bd1656b0cad8053a03a)

emaste commented 1 year ago

Found two more via Clang static analyzer just now:

Bug reported by the clang static analyzer.

Description: Value stored to 'stream_code' is never read
File: /usr/home/emaste/src/gitup/gitup.c
Line: 2339
Bug reported by the clang static analyzer.

Description: Value stored to 'temp' is never read
File: /usr/home/emaste/src/gitup/gitup.c
Line: 3686
emaste commented 1 year ago

Also two of another type

Bug reported by the clang static analyzer.

Description: Although the value stored to 'object' is used in the enclosing expression, the value is never actually read from 'object'
File: /usr/home/emaste/src/gitup/gitup.c
Line: 1140
Bug reported by the clang static analyzer.

Description: Although the value stored to 'entry' is used in the enclosing expression, the value is never actually read from 'entry'
File: /usr/home/emaste/src/gitup/gitup.c
Line: 4103
nunotexbsd commented 1 year ago

fixes clang 16 build and run test ok at main-n263928-005aa1743b42

commit https://cgit.freebsd.org/ports/commit/?id=deb4a46338300fb1f2145af29484b48bd26d69d4

Thanks

johnmehr commented 1 year ago

I installed llvm 16 and ran its scan-build/scan-view and the remaining four errors are all related to FreeBSD's tree.h code and (unless I'm missing something super subtle) they all look like false positives.