I fixed gcc warnings related to signedness

View: New views
1 Messages — Rating Filter:   Alert me  

I fixed gcc warnings related to signedness

by Bugzilla from WillyFoobar@gmx.de :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Michael,
Hello Yuri,
Hello to all Trackers,

I had a little time to fix the gcc compiler warnings related to
the illegal signedness.

the reason for signess errors is that functions like
        strncm(char* , char* , int n);
expext an pointer to a simple  char, which is by definition a "signed char".

I added some cast to (char*),
an other (perhaps more usable) way would be to declare the related variables
        as signed char
what is declaring as "gint8"and not as "guint8"

It may be a little bit uncouraged of my person,
but I do not feel good to modify the type of a variable, when I don't know,
if this special (actual) signedness is done by purpose.
But I believe you should change the types of the variables at least for the
vectors
gint8 a[], b[];
which occure in several functions at different places.
(do a
        >grep -r (char\*) *
to get the locations where I have done changes.




the soundtracker-0.6.8 now compiles through without any warnings
related to "signedness errors".

Still there is a weired error  fiddeling around with "strict-aliasing rules"
-------------------------------- like ----------------------------------------
envelope-box.c:878: warning:
dereferencing type-punned pointer will break strict-aliasing rules                                            
-----------------------------------------------------------------------------


Yours,
        Willy

P.S.: see the diff file relative to the changes,
I did in my earlietr mail
        "compiling failure soundtracker-v0.6.8 without package libsndfile"

> Here is the result of the command
>       diff -r soundtracker-0.6.8-willyfoobar soundtracker-0.6.8-willyfoobar2
> attached as a file to this mail.


[soundtracker-0.6.8-willyfoobar2.diff]

diff -r soundtracker-0.6.8-willyfoobar/app/clavier.c soundtracker-0.6.8-willyfoobar2/app/clavier.c
63c63
< static gint clavier_signals[LAST_SIGNAL] = {0};
---
> static guint clavier_signals[LAST_SIGNAL] = {0};
diff -r soundtracker-0.6.8-willyfoobar/app/gui-settings.c soundtracker-0.6.8-willyfoobar2/app/gui-settings.c
559c559
<    prefs_get_int(f, "permanent-channels", &gui_settings.permanent_channels);
---
>    prefs_get_int(f, "permanent-channels", (gint32*)&gui_settings.permanent_channels);
diff -r soundtracker-0.6.8-willyfoobar/app/track-editor.c soundtracker-0.6.8-willyfoobar2/app/track-editor.c
1261c1261
<  gint8 *modpt,
---
>  guint8 *modpt,
1288c1288
<      gint8 *modpt,
---
>      guint8 *modpt,
diff -r soundtracker-0.6.8-willyfoobar/app/xm.c soundtracker-0.6.8-willyfoobar2/app/xm.c
305c305
< strncpy(s->name, sh + 18, 22);
---
> strncpy(s->name, (char*)sh + 18, 22);
387,388c387,388
< strncpy(sh + 18, s->name, 22);
< recode_latin1_to_ibmpc(sh + 18, 22);
---
> strncpy((char*)sh + 18, s->name, 22);
> recode_latin1_to_ibmpc((char*) sh + 18, 22);
464c464
<     strncpy(instr->name, a + 4, 22);
---
>     strncpy(instr->name, (char*)a + 4, 22);
546c546
<     if(strcmp(a, "Extended Instrument: ")) {
---
>     if(strcmp((char*)a, "Extended Instrument: ")) {
552c552
<     strncpy(instr->name, a, 22);
---
>     strncpy(instr->name, (char*)a, 22);
557,558c557,558
< sprintf(b, _("Unknown XI version 0x%x\n"), get_le_16(a+21));
< error_error(b);
---
> sprintf((char*)b, _("Unknown XI version 0x%x\n"), get_le_16(a+21));
> error_error((char*)b);
614,615c614,615
<     strncpy(a, instr->name, 22);
<     recode_latin1_to_ibmpc(a, 22);
---
>     strncpy((char*)a, instr->name, 22);
>     recode_latin1_to_ibmpc((char*)a, 22);
668,669c668,669
<     strncpy(h + 4, instr->name, 22);
<     recode_latin1_to_ibmpc(h + 4, 22);
---
>     strncpy((char*)h + 4, instr->name, 22);
>     recode_latin1_to_ibmpc((char*)h + 4, 22);
934c934
<        || strncmp(xh + 0, "Extended Module: ", 17) != 0
---
>        || strncmp((char*)xh + 0, "Extended Module: ", 17) != 0
957c957
<     strncpy(xm->name, xh + 17, 20);
---
>     strncpy(xm->name, (char*) xh + 17, 20);
1043c1043
<     recode_latin1_to_ibmpc(xh + 17, 20);
---
>     recode_latin1_to_ibmpc((char*)xh + 17, 20);
diff -r soundtracker-0.6.8-willyfoobar/ChangeLog soundtracker-0.6.8-willyfoobar2/ChangeLog
0a1,8
> 2006-11-11  Frank haferkorn <WillyFoobar@...>
>
> * app/*.c
>  fixed compiler warnings that are related to illegal signedness
>           sometimes the fix by casting from guint8 to (char*)
>  could better be done by changing the declaration of the variables from guint8 to gint8
>  simply look for "(char*)" and modify the type of the variables (like 'a[]' and 'b[]')
>      


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Soundtracker-discuss mailing list
Soundtracker-discuss@...
https://lists.sourceforge.net/lists/listinfo/soundtracker-discuss