Fix: Add block scope for variable declarations in switch case 'u'#503
Fix: Add block scope for variable declarations in switch case 'u'#503slp merged 1 commit intocontainers:mainfrom
Conversation
Signed-off-by: Mathieu Chassara <mathieu.chassara@gmail.com>
53d6c26 to
14400e9
Compare
slp
left a comment
There was a problem hiding this comment.
@mchassara thanks for the PR! It's interesting that some compilers doesn't complain about this. In any case, let's get this fixed.
|
Obviously one should always use a Turns out this is in fact valid C, but from C23 onwards 😆 (and it's also valid in C++) We should probably specify a C version explicitly in the Makefile... |
|
Thank you @mtjhrc for the investigation, I wasn't brave enough to check all the C versions and I've stopped coding C since few years now. 😅 @slp For the record, I found the bug while trying to install https://github.com/nohajc/anylinuxfs (cc @nohajc) |
|
@mchassara You're still running an older version of macOS, right? There's a libkrun bottle for Tahoe. I still provide one for Sequoia too. Otherwise it'll build from source. |
Running on Sonoma 14.8.3 indeed! |
Problem
Related to #501
The
case 'u':label in the JSON string parser's switch statement declares variables (unicodeandascii) directly after the case label. In C, this is invalid syntax because all case labels share the same scope, and variable declarations require a proper block scope.Solution
Wrapped the
case 'u':block in curly braces{ }to create a proper scope for the variable declarations. This ensures the code compiles correctly and follows standard C syntax.Changes
{aftercase 'u':on line 240}before thedefault:case on line 273Testing
The code should now compile without errors. The functionality remains unchanged - this is purely a syntax fix.