From 7959aa4cda19e10a4ae991999898c5974a118c9e Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Thu, 18 Dec 2014 12:30:49 -0600 Subject: [PATCH] wmcdplay: Fix -Wwrite-string compiler warnings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, compiling wmcdplay caused a large number of warnings of the form "deprecated conversion from string constant to ‘char*’". This was fixed by changing "char *" declarations to "const char *", especially in the .xpm files, and using "const_cast" as needed when an external library expected a non-const. --- wmcdplay/ARTWORK | 10 +++++----- wmcdplay/XPM/bluered/cdplayer.xpm | 2 +- wmcdplay/XPM/bluered/led.xpm | 2 +- wmcdplay/XPM/bluered/ledsym.xpm | 2 +- wmcdplay/XPM/bluered/ledtsel.xpm | 2 +- wmcdplay/XPM/bluered/symbols.xpm | 2 +- wmcdplay/XPM/grey/cdplayer.xpm | 2 +- wmcdplay/XPM/grey/led.xpm | 2 +- wmcdplay/XPM/grey/ledsym.xpm | 2 +- wmcdplay/XPM/grey/ledtsel.xpm | 2 +- wmcdplay/XPM/grey/symbols.xpm | 2 +- wmcdplay/XPM/newstyle/cdplayer.xpm | 2 +- wmcdplay/XPM/newstyle/led.xpm | 2 +- wmcdplay/XPM/newstyle/ledsym.xpm | 2 +- wmcdplay/XPM/newstyle/ledtsel.xpm | 2 +- wmcdplay/XPM/newstyle/symbols.xpm | 2 +- wmcdplay/XPM/tile.xpm | 2 +- wmcdplay/XPM/wmcd/cdplayer.xpm | 2 +- wmcdplay/XPM/wmcd/led.xpm | 2 +- wmcdplay/XPM/wmcd/ledsym.xpm | 2 +- wmcdplay/XPM/wmcd/ledtsel.xpm | 2 +- wmcdplay/XPM/wmcd/symbols.xpm | 2 +- wmcdplay/wmcdplay.cc | 32 ++++++++++++++++-------------- 23 files changed, 43 insertions(+), 41 deletions(-) diff --git a/wmcdplay/ARTWORK b/wmcdplay/ARTWORK index ece3395..120a78f 100644 --- a/wmcdplay/ARTWORK +++ b/wmcdplay/ARTWORK @@ -73,7 +73,7 @@ led.xpm This file must begin with these 2 lines (character perfect): /* XPM */ -static char * led_xpm[] = { +static const char * led_xpm[] = { ledsym.xpm ---------- @@ -86,7 +86,7 @@ ledsym.xpm This file must begin with these 2 lines (character perfect): /* XPM */ -static char * ledsym_xpm[] = { +static const char * ledsym_xpm[] = { ledtsel.xpm ----------- @@ -100,7 +100,7 @@ ledtsel.xpm This file must begin with these 2 lines (character perfect): /* XPM */ -static char * ledtsel_xpm[] = { +static const char * ledtsel_xpm[] = { symbols.xpm ----------- @@ -113,7 +113,7 @@ symbols.xpm This file must begin with these 2 lines (character perfect): /* XPM */ -static char * symbols_xpm[] = { +static const char * symbols_xpm[] = { cdplayer.xpm ------------ @@ -129,7 +129,7 @@ cdplayer.xpm This file must begin with these 2 lines (character perfect): /* XPM */ -static char * cdplayer_xpm[] = { +static const char * cdplayer_xpm[] = { THE DATA FILE - artwork.dat diff --git a/wmcdplay/XPM/bluered/cdplayer.xpm b/wmcdplay/XPM/bluered/cdplayer.xpm index 54ce780..3d439cf 100644 --- a/wmcdplay/XPM/bluered/cdplayer.xpm +++ b/wmcdplay/XPM/bluered/cdplayer.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * cdplayer_xpm[] = { +static const char * cdplayer_xpm[] = { "64 64 64 1", " c None", ". c #FFFF00000000", diff --git a/wmcdplay/XPM/bluered/led.xpm b/wmcdplay/XPM/bluered/led.xpm index f4b5d53..e80580c 100644 --- a/wmcdplay/XPM/bluered/led.xpm +++ b/wmcdplay/XPM/bluered/led.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * led_xpm[] = { +static const char * led_xpm[] = { "171 11 4 1", " c #000000", "0 c #00ff00 s led_color_high", diff --git a/wmcdplay/XPM/bluered/ledsym.xpm b/wmcdplay/XPM/bluered/ledsym.xpm index 01be3df..8814b31 100644 --- a/wmcdplay/XPM/bluered/ledsym.xpm +++ b/wmcdplay/XPM/bluered/ledsym.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * ledsym_xpm[] = { +static const char * ledsym_xpm[] = { "35 5 2 1", " c #000000", "0 c #00ff00 s led_color_high", diff --git a/wmcdplay/XPM/bluered/ledtsel.xpm b/wmcdplay/XPM/bluered/ledtsel.xpm index 51a7cce..bf1914b 100644 --- a/wmcdplay/XPM/bluered/ledtsel.xpm +++ b/wmcdplay/XPM/bluered/ledtsel.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * ledtsel_xpm[]={ +static const char * ledtsel_xpm[]={ "29 11 2 1", " c #000000", "0 c #00ff00 s led_color_high", diff --git a/wmcdplay/XPM/bluered/symbols.xpm b/wmcdplay/XPM/bluered/symbols.xpm index 62a2609..6560f02 100644 --- a/wmcdplay/XPM/bluered/symbols.xpm +++ b/wmcdplay/XPM/bluered/symbols.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * symbols_xpm[] = { +static const char * symbols_xpm[] = { "131 11 18 1", " c None", ". c #DF7DDF7DDF7D", diff --git a/wmcdplay/XPM/grey/cdplayer.xpm b/wmcdplay/XPM/grey/cdplayer.xpm index 5f6e73e..0f0a686 100644 --- a/wmcdplay/XPM/grey/cdplayer.xpm +++ b/wmcdplay/XPM/grey/cdplayer.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * cdplayer_xpm[] = { +static const char * cdplayer_xpm[] = { "64 64 5 1", " c None", "0 c #414141", diff --git a/wmcdplay/XPM/grey/led.xpm b/wmcdplay/XPM/grey/led.xpm index f4b5d53..e80580c 100644 --- a/wmcdplay/XPM/grey/led.xpm +++ b/wmcdplay/XPM/grey/led.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * led_xpm[] = { +static const char * led_xpm[] = { "171 11 4 1", " c #000000", "0 c #00ff00 s led_color_high", diff --git a/wmcdplay/XPM/grey/ledsym.xpm b/wmcdplay/XPM/grey/ledsym.xpm index 01be3df..8814b31 100644 --- a/wmcdplay/XPM/grey/ledsym.xpm +++ b/wmcdplay/XPM/grey/ledsym.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * ledsym_xpm[] = { +static const char * ledsym_xpm[] = { "35 5 2 1", " c #000000", "0 c #00ff00 s led_color_high", diff --git a/wmcdplay/XPM/grey/ledtsel.xpm b/wmcdplay/XPM/grey/ledtsel.xpm index 51a7cce..bf1914b 100644 --- a/wmcdplay/XPM/grey/ledtsel.xpm +++ b/wmcdplay/XPM/grey/ledtsel.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * ledtsel_xpm[]={ +static const char * ledtsel_xpm[]={ "29 11 2 1", " c #000000", "0 c #00ff00 s led_color_high", diff --git a/wmcdplay/XPM/grey/symbols.xpm b/wmcdplay/XPM/grey/symbols.xpm index b1c6c12..6091a8d 100644 --- a/wmcdplay/XPM/grey/symbols.xpm +++ b/wmcdplay/XPM/grey/symbols.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * symbols_xpm[] = { +static const char * symbols_xpm[] = { "65 5 2 1", " c None", "0 c #000000", diff --git a/wmcdplay/XPM/newstyle/cdplayer.xpm b/wmcdplay/XPM/newstyle/cdplayer.xpm index 8261d6d..d6a9cec 100644 --- a/wmcdplay/XPM/newstyle/cdplayer.xpm +++ b/wmcdplay/XPM/newstyle/cdplayer.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * cdplayer_xpm[] = { +static const char * cdplayer_xpm[] = { "64 64 8 1", " c None", ". c #000000", diff --git a/wmcdplay/XPM/newstyle/led.xpm b/wmcdplay/XPM/newstyle/led.xpm index a55568f..3d1d7e1 100644 --- a/wmcdplay/XPM/newstyle/led.xpm +++ b/wmcdplay/XPM/newstyle/led.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * led_xpm[] = { +static const char * led_xpm[] = { "128 9 3 1", " c #282828 s color_back", "1 c #006200 s led_color_low", diff --git a/wmcdplay/XPM/newstyle/ledsym.xpm b/wmcdplay/XPM/newstyle/ledsym.xpm index f9469dc..dc30e84 100644 --- a/wmcdplay/XPM/newstyle/ledsym.xpm +++ b/wmcdplay/XPM/newstyle/ledsym.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * ledsym_xpm[] = { +static const char * ledsym_xpm[] = { "59 9 3 1", " c #282828 s color_back", "0 c #00ff00 s led_color_high", diff --git a/wmcdplay/XPM/newstyle/ledtsel.xpm b/wmcdplay/XPM/newstyle/ledtsel.xpm index fbfafaf..3755b8e 100644 --- a/wmcdplay/XPM/newstyle/ledtsel.xpm +++ b/wmcdplay/XPM/newstyle/ledtsel.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * ledtsel_xpm[] = { +static const char * ledtsel_xpm[] = { "69 7 2 1", " c #282828 s color_back", "0 c #00ff00 s led_color_high", diff --git a/wmcdplay/XPM/newstyle/symbols.xpm b/wmcdplay/XPM/newstyle/symbols.xpm index 3e716c7..524a669 100644 --- a/wmcdplay/XPM/newstyle/symbols.xpm +++ b/wmcdplay/XPM/newstyle/symbols.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * symbols_xpm[] = { +static const char * symbols_xpm[] = { "65 5 2 1", " c None", "0 c #000000", diff --git a/wmcdplay/XPM/tile.xpm b/wmcdplay/XPM/tile.xpm index e65c234..a0d6fdb 100644 --- a/wmcdplay/XPM/tile.xpm +++ b/wmcdplay/XPM/tile.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char *tile_xpm[] = { +static const char *tile_xpm[] = { "64 64 54 1", " c #F3CEF3CEF3CE", ". c #000000000000", diff --git a/wmcdplay/XPM/wmcd/cdplayer.xpm b/wmcdplay/XPM/wmcd/cdplayer.xpm index 8796f2f..ed23b5c 100644 --- a/wmcdplay/XPM/wmcd/cdplayer.xpm +++ b/wmcdplay/XPM/wmcd/cdplayer.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * cdplayer_xpm[] = { +static const char * cdplayer_xpm[] = { "64 64 6 1", " c None", ". c #410341034103", diff --git a/wmcdplay/XPM/wmcd/led.xpm b/wmcdplay/XPM/wmcd/led.xpm index f4b5d53..e80580c 100644 --- a/wmcdplay/XPM/wmcd/led.xpm +++ b/wmcdplay/XPM/wmcd/led.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * led_xpm[] = { +static const char * led_xpm[] = { "171 11 4 1", " c #000000", "0 c #00ff00 s led_color_high", diff --git a/wmcdplay/XPM/wmcd/ledsym.xpm b/wmcdplay/XPM/wmcd/ledsym.xpm index 01be3df..8814b31 100644 --- a/wmcdplay/XPM/wmcd/ledsym.xpm +++ b/wmcdplay/XPM/wmcd/ledsym.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * ledsym_xpm[] = { +static const char * ledsym_xpm[] = { "35 5 2 1", " c #000000", "0 c #00ff00 s led_color_high", diff --git a/wmcdplay/XPM/wmcd/ledtsel.xpm b/wmcdplay/XPM/wmcd/ledtsel.xpm index 51a7cce..bf1914b 100644 --- a/wmcdplay/XPM/wmcd/ledtsel.xpm +++ b/wmcdplay/XPM/wmcd/ledtsel.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * ledtsel_xpm[]={ +static const char * ledtsel_xpm[]={ "29 11 2 1", " c #000000", "0 c #00ff00 s led_color_high", diff --git a/wmcdplay/XPM/wmcd/symbols.xpm b/wmcdplay/XPM/wmcd/symbols.xpm index 6c759ad..8b19f2a 100644 --- a/wmcdplay/XPM/wmcd/symbols.xpm +++ b/wmcdplay/XPM/wmcd/symbols.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * symbols_xpm[] = { +static const char * symbols_xpm[] = { "87 7 26 1", " c None", ". c #CF3CCF3CCF3C", diff --git a/wmcdplay/wmcdplay.cc b/wmcdplay/wmcdplay.cc index 78c544b..0108b89 100644 --- a/wmcdplay/wmcdplay.cc +++ b/wmcdplay/wmcdplay.cc @@ -146,7 +146,7 @@ void readArrayInt(char *buf, int *array, int n); void readArrayBool(char *buf, bool *array, int n); // Procedures and functions - artwork specials -void createPixmap(char **data, char *buf, Pixmap *image, Pixmap *mask, int *width, int *height); +void createPixmap(const char **data, char *buf, Pixmap *image, Pixmap *mask, int *width, int *height); void setBtnList(int *bset); bool inPolygon(int *points, int px, int py); @@ -320,8 +320,8 @@ void freeXWin(){ void createWin(Window *win, int x, int y){ XClassHint classHint; *win=XCreateSimpleWindow(d_display, w_root, x, y, winsize, winsize, 0, 0, 0); - classHint.res_name=NAME; - classHint.res_class=CLASS; + classHint.res_name=const_cast(NAME); + classHint.res_class=const_cast(CLASS); XSetClassHint(d_display, *win, &classHint); } @@ -649,7 +649,7 @@ bool readArtwork(char *artfilen){ if(!done){ int keynum=0; - char *keystr[]={ "int art_nbtns=", + const char *keystr[]={ "int art_nbtns=", "bool art_hidebtns=", "bool art_showled[4]=", "int art_ledpos[4][2]=", @@ -697,24 +697,24 @@ bool readArtwork(char *artfilen){ *strchr(buf, '\n')='\0'; int w,h; - if(strncmp(buf, "static char * cdplayer_xpm", strlen("static char * cdplayer_xpm"))==0) + if(strncmp(buf, "static const char * cdplayer_xpm", strlen("static const char * cdplayer_xpm"))==0) createPixmap(NULL, block, &pm_cd, &pm_cdmask, NULL, NULL); - if(strncmp(buf, "static char * symbols_xpm", strlen("static char * symbols_xpm"))==0){ + if(strncmp(buf, "static const char * symbols_xpm", strlen("static const char * symbols_xpm"))==0){ createPixmap(NULL, block, &pm_sym, &pm_symmask, &w, &h); art_symsize[0]=(w+1)/11-1; art_symsize[1]=h; } - if(strncmp(buf, "static char * led_xpm", strlen("static char * led_xpm"))==0){ + if(strncmp(buf, "static const char * led_xpm", strlen("static const char * led_xpm"))==0){ createPixmap(NULL, block, &pm_led, NULL, &w, &h); art_ledsize[0]=(w+1)/strlen(chrset)-1; art_ledsize[1]=h; } - if(strncmp(buf, "static char * ledsym_xpm", strlen("static char * ledsym_xpm"))==0){ + if(strncmp(buf, "static const char * ledsym_xpm", strlen("static const char * ledsym_xpm"))==0){ createPixmap(NULL, block, &pm_sled, NULL, &w, &h); art_ledsize[2]=(w+1)/6-1; art_ledsize[3]=h; } - if(strncmp(buf, "static char * ledtsel_xpm", strlen("static char * ledtsel_xpm"))==0){ + if(strncmp(buf, "static const char * ledtsel_xpm", strlen("static const char * ledtsel_xpm"))==0){ createPixmap(NULL, block, &pm_tled, NULL, &w, &h); art_ledsize[4]=(w+1)/5-1; art_ledsize[5]=h; @@ -771,19 +771,21 @@ void readArrayBool(char *buf, bool *array, int n){ } } -void createPixmap(char **data, char *buf, Pixmap *image, Pixmap *mask, int *width, int *height){ +void createPixmap(const char **data, char *buf, Pixmap *image, Pixmap *mask, int *width, int *height){ XpmAttributes xpmattr; - XpmColorSymbol xpmcsym[4]={{"back_color", NULL, color[0]}, - {"led_color_high", NULL, color[1]}, - {"led_color_med", NULL, color[2]}, - {"led_color_low", NULL, color[3]}}; + XpmColorSymbol xpmcsym[4]={ + {const_cast("back_color"), NULL, color[0]}, + {const_cast("led_color_high"), NULL, color[1]}, + {const_cast("led_color_med"), NULL, color[2]}, + {const_cast("led_color_low"), NULL, color[3]}}; xpmattr.numsymbols=4; xpmattr.colorsymbols=xpmcsym; xpmattr.exactColors=false; xpmattr.closeness=40000; xpmattr.valuemask=XpmColorSymbols | XpmExactColors | XpmCloseness | XpmSize; if(data!=NULL) - XpmCreatePixmapFromData(d_display, w_root, data, image, mask, &xpmattr); + XpmCreatePixmapFromData(d_display, w_root, const_cast(data), + image, mask, &xpmattr); else XpmCreatePixmapFromBuffer(d_display, w_root, buf, image, mask, &xpmattr); if(width!=NULL)