Skip to content

1.14: Bug compiling from source on Raspberry Pi 4B, and fixing it #67

Description

@csejourne

Hello,

I was trying to compile snapraid-daemon v.1.14 from source, as there is no packaged version on the Linux distribution running on my RPI 4B. I followed the instruction in the INSTALL file, but I couldn't compile when running make and it gave me the following error (cutting some lines before).

daemon/parser.c: In function ‘parse_log’:
daemon/parser.c:1795:7: error: label at end of compound statement
 1795 |       default : /* ignore if unknown */
      |       ^~~~~~~
make[1]: *** [Makefile:775: daemon/snapraidd-parser.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/csej/customs_builds/snapraid-daemon-1.13'
make: *** [Makefile:549: all] Error 2

My OS Information: I am running Debian 11 (bullseye) on the aarch64, and the Linux version is 6.1.21-v8+.

Fixing this error: I simply modified the daemon/parser.c around the line 1795 as followed:

/* insert in the de-escaped plain */
if (escape) {
        if (plain_len + 1 < RUN_INPUT_MAX) { /* ignore if too long */
                switch (c) {
                case '\\' : plain[plain_len++] = '\\'; break;
                case 'n' :  plain[plain_len++] = '\n'; break;
                case 'd' : plain[plain_len++] = ':'; break;
                default : /* ignore if unknown */
                           break;                            // <--- LINE ADDED
                }
        }
        escape = 0;
        continue;
}

To be completely transparent, I asked an LLM to help with this, as I am definitely not a C aficionado. The LLM told me it is about the fact that the compiler on my machine uses the C standard C17, which does not accept such syntax. The LLM answer is:

"A default: label with nothing after it before the closing brace. That's a constraint violation in C17, so GCC errors out. C23 relaxed this (N2508, free positioning of labels in compound statements), which is why it compiles fine for the author."

After this change, the code compiles fine, and I was able to do sudo make install

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdone

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions