On Sun, Nov 17, 2024 at 04:03:29AM -0500, Jeff King wrote: > On Sun, Nov 17, 2024 at 02:50:39AM +0000, Sam James wrote: > > > With upcoming GCC 15, a new warning is added > > (-Wunterminated-string-initialization) that fires when building git: > > ``` > > CC object-file.o > > object-file.c:52:9: warning: initializer-string for array of ‘unsigned char’ is too long [-Wunterminated-string-initialization] > > 52 | "\x6e\xf1\x9b\x41\x22\x5c\x53\x69\xf1\xc1" \ > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > object-file.c:79:17: note: in expansion of macro ‘EMPTY_TREE_SHA256_BIN_LITERAL’ > > 79 | .hash = EMPTY_TREE_SHA256_BIN_LITERAL, > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > object-file.c:61:9: warning: initializer-string for array of ‘unsigned char’ is too long [-Wunterminated-string-initialization] > > 61 | "\x47\x3a\x0f\x4c\x3b\xe8\xa9\x36\x81\xa2" \ > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > object-file.c:83:17: note: in expansion of macro ‘EMPTY_BLOB_SHA256_BIN_LITERAL’ > > 83 | .hash = EMPTY_BLOB_SHA256_BIN_LITERAL, > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > ``` > > > > Context for the new warning is at https://gcc.gnu.org/PR115185. > > I think the warning is a false positive for us, but I don't begrudge > them for adding it. It could definitely catch real problems. > > Here are some patches. The first one should fix the warning (but I don't > have gcc-15 handy to test!). Please let me know if it works for you (and > thank you for reporting). > > The others are cleanups and future-proofing I found in the same area. > Not strictly required, but IMHO worth doing. > > +cc brian since I think this is a continuation of some hash-algo > cleanups he did earlier, plus he piped up in the other gcc-15 thread. ;) I've got two comments, but other than that this looks like a nice cleanup to me. Thanks! Patrick