RevoGirl / RevoBoot

The RevoBoot-loader project
http://revogirl.wordpress.com/
Other
50 stars 138 forks source link

10.7.3 compilation error: assignment as a condition without parentheses #24

Closed brycv closed 12 years ago

brycv commented 12 years ago

Below is the result of my attempt to compile RevoBoot. I used RevoBuilder for this process but then tried to compile manually with the same result. It appears to be an easy fix but I'm not entirely sure what the unintended consequences might be so I though I would submit an issue instead.

================= make all for libsa =================
/bin/mkdir -p /Users/username/Downloads/blackosx-RevoBuilder-4fb09e3/RevoBoot_SourceCode/RevoBoot-1.0.22/obj/i386/libsa
cc   -Os -Oz  -arch i386 -g -Wmost -Werror -fno-builtin -static  -mpreferred-stack-boundary=2 -fno-align-functions -fno-stack-protector -march=pentium4 -msse2 -mfpmath=sse -msoft-float  -c -I. -I/Users/username/Downloads/blackosx-RevoBuilder-4fb09e3/RevoBoot_SourceCode/RevoBoot-1.0.22/sym/i386 -I../util -I../libsaio prf.c -o /Users/username/Downloads/blackosx-RevoBuilder-4fb09e3/RevoBoot_SourceCode/RevoBoot-1.0.22/obj/i386/libsa/prf.o \
        -MD -dependency-file /Users/username/Downloads/blackosx-RevoBuilder-4fb09e3/RevoBoot_SourceCode/RevoBoot-1.0.22/obj/i386/libsa/prf.d
clang: warning: argument unused during compilation: '-mpreferred-stack-boundary=2'
clang: warning: argument unused during compilation: '-fno-align-functions'
clang: warning: argument unused during compilation: '-mfpmath=sse'
prf.c:148:12: error: using the result of an assignment as a condition without
      parentheses [-Werror,-Wparentheses]
                while (c = *s++) {
                       ~~^~~~~~
prf.c:148:12: note: place parentheses around the assignment to silence this
      warning
                while (c = *s++) {
                         ^
                       (       )
prf.c:148:12: note: use '==' to turn this assignment into an equality comparison
                while (c = *s++) {
                         ^
                         ==
1 error generated.
make[2]: *** [prf.o] Error 1
make[1]: *** [all] Error 2
make: *** [all] Error 2

Compilation of RevoBoot for LION Failed.

Press any key to return to the main menu
RevoGirl commented 12 years ago

I do have OS X 10.7.3 with Xcode 4.3 installed, but I don't get this error. You changed the Makefile?

brycv commented 12 years ago

I tried changing the Makefile but my change did not work. Is that the proper way to deal with the error? It's possible my Xcode install has too many old versions underneath or something. I'm installing Xcode 4.3 on a clean system right now. We'll see what happens.

brycv commented 12 years ago

I fixed the issues but I'm not sure if this is the right way to do it. Modifications to three files were required because there were multiple errors. I was able to get a successful compile after these patches. I didn't create my patches correctly apparently so I can't apply them to the tree but you can see the changes.

Update: I fixed the patch. It can be applied in the RevoBoot-1.0.22 directory with patch -p1.

diff -ru RevoBoot-1.0.22/i386/libsa/prf.c RevoBoot-1.0.22.patched/i386/libsa/prf.c
--- RevoBoot-1.0.22/i386/libsa/prf.c    2012-03-05 16:12:44.000000000 -0800
+++ RevoBoot-1.0.22.patched/i386/libsa/prf.c    2012-03-05 16:16:16.000000000 -0800
@@ -145,7 +145,7 @@
        break;
    case 's':
        s = (char *)*adx;
-       while (c = *s++) {
+       while ((c = *s++)) {
            (*putfn_p)(c, putfn_arg);
            width++;
        }
diff -ru RevoBoot-1.0.22/i386/libsa/string.c RevoBoot-1.0.22.patched/i386/libsa/string.c
--- RevoBoot-1.0.22/i386/libsa/string.c 2012-03-05 16:12:44.000000000 -0800
+++ RevoBoot-1.0.22.patched/i386/libsa/string.c 2012-03-05 16:16:37.000000000 -0800
@@ -148,7 +148,7 @@
 char * strcpy(char * s1, const char * s2)
 {
    register char *ret = s1;
-   while (*s1++ = *s2++)
+   while ((*s1++ = *s2++))
        continue;
    return ret;
 }
diff -ru RevoBoot-1.0.22/i386/libsa/strtol.c RevoBoot-1.0.22.patched/i386/libsa/strtol.c
--- RevoBoot-1.0.22/i386/libsa/strtol.c 2012-03-05 16:12:44.000000000 -0800
+++ RevoBoot-1.0.22.patched/i386/libsa/strtol.c 2012-03-05 16:17:17.000000000 -0800
@@ -179,7 +179,7 @@
            break;
        if (c >= base)
            break;
-       if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+       if (any < 0 || acc > cutoff || acc == (cutoff && c > cutlim))
            any = -1;
        else {
            any = 1;
@@ -251,7 +251,7 @@
            break;
        if (c >= base)
            break;
-       if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+       if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
            any = -1;
        else {
            any = 1;
@@ -322,7 +322,7 @@
            break;
        if (c >= base)
            break;
-       if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+       if (any < 0 || acc > cutoff || acc == (cutoff && c > cutlim))
            any = -1;
        else {
            any = 1;
RevoGirl commented 12 years ago

Thanks,

And this is quite interesting. I mean is that really everything we have to change (Chameleon had a lot more errors).

I am going to re-install Xcode to see if I can get Clang to throw errors on my system.

brycv commented 12 years ago

It's been an annoying process going from Xcode 4.1 to 4.2 to 4.3 with significant changes each time. 4.1 still had gcc while 4.2 does not. I couldn't get some things working at all (octopress/rvm) without reinstalling 4.1 and then installing 4.2. 4.3 is now a separate app and no longer uses /Developer at all. Now there's a different way to install command line tools also via Preferences & Downloads in the Xcode.app version 4.3.

RevoGirl commented 12 years ago

Right. I knew that I forgot something, but I couldn't figure out what. Thanks.

I installed the command line tools and was able to fix the errors reported by Clang but I have yet to verify my changes.

brycv commented 12 years ago

No problem. I had to do a clean install on another system to figure out what was wrong and figured you might need it too.