Set warnings as errors.

Const correct massaging to lose the couple warnings that were there.
This commit is contained in:
Mike Small 2017-10-01 00:02:51 -04:00
parent 5cfb5bf2e7
commit 30e2e57a58
7 changed files with 39 additions and 26 deletions

View File

@ -1,3 +1,16 @@
2017-09-30 Michael Small <smallm@sdf.org>
* src/Makefile.am (AM_CFLAGS): warnings as errors.
* src/menus.c (ExecuteFunction): ptr as const char* to prevent const
qualifier discard warnings when passed const char* action.
* src/util.c (ExpandFilename): use const char* for arg and return value.
(FindBitmap): cast return val of ExpandFilename to char* for bigname.
Should be harmless since it's used as constant data up to it being
assigned something else.
(GetFont): Similar case here but without ExpandFilename being involved.
* src/screen.h (ScreenInfo): IconDirectory can be const char* too,
avoiding warning in parse.c:771.
2017-09-27 Michael Small <smallm@sdf.org>
Preliminaries:

View File

@ -32,7 +32,7 @@ AM_CPPFLAGS = \
-DXORG_RELEASE=\"Release\ $(VERSION)\" \
-DSYSTEM_INIT_FILE=\"${datadir}/X11/twmruined/system.twmruinedrc\"
AM_CFLAGS = $(TWM_CFLAGS)
AM_CFLAGS = -Werror $(TWM_CFLAGS)
twmruined_LDADD = $(TWM_LIBS)
twmruined_SOURCES = \

View File

@ -366,7 +366,7 @@ AM_CPPFLAGS = \
-DXORG_RELEASE=\"Release\ $(VERSION)\" \
-DSYSTEM_INIT_FILE=\"${datadir}/X11/twmruined/system.twmruinedrc\"
AM_CFLAGS = $(TWM_CFLAGS)
AM_CFLAGS = -Werror $(TWM_CFLAGS)
twmruined_LDADD = $(TWM_LIBS)
twmruined_SOURCES = \
add_window.c \

View File

@ -1293,7 +1293,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
{
static Time last_time = 0;
char tmp[200];
char *ptr;
const char *ptr;
char buff[MAX_FILE_SIZE];
int count, fd;
Window rootw;
@ -2006,24 +2006,24 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
case F_CUTFILE:
ptr = XFetchBytes(dpy, &count);
if (ptr) {
if (sscanf (ptr, "%s", tmp) == 1) {
XFree (ptr);
if (sscanf(ptr, "%s", tmp) == 1) {
XFree((void*)ptr);
ptr = ExpandFilename(tmp);
if (ptr) {
fd = open (ptr, O_RDONLY);
fd = open(ptr, O_RDONLY);
if (fd >= 0) {
count = read (fd, buff, MAX_FILE_SIZE - 1);
if (count > 0) XStoreBytes (dpy, buff, count);
count = read(fd, buff, MAX_FILE_SIZE - 1);
if (count > 0) XStoreBytes(dpy, buff, count);
close(fd);
} else {
fprintf (stderr,
"%s: unable to open cut file \"%s\"\n",
ProgramName, tmp);
fprintf(stderr,
"%s: unable to open cut file \"%s\"\n",
ProgramName, tmp);
}
if (ptr != tmp) free (ptr);
if (ptr != tmp) free((void*)ptr);
}
} else {
XFree(ptr);
XFree((void*)ptr);
}
} else {
fprintf(stderr, "%s: cut buffer is empty\n", ProgramName);
@ -2185,7 +2185,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
fprintf (stderr, "%s: unable to open file \"%s\"\n",
ProgramName, ptr);
}
if (ptr != action) free(ptr);
if (ptr != action) free((void*)ptr);
break;
case F_REFRESH:

View File

@ -195,7 +195,7 @@ typedef struct ScreenInfo
IconMgr iconmgr; /* default icon manager */
struct IconRegion *FirstRegion; /* pointer to icon regions */
struct IconRegion *LastRegion; /* pointer to the last icon region */
char *IconDirectory; /* icon directory to search */
const char *IconDirectory; /* icon directory to search */
int SizeStringOffset; /* x offset in size window for drawing */
int SizeStringWidth; /* minimum width of size window */
int BorderWidth; /* border width of twm windows */

View File

@ -255,21 +255,21 @@ Zoom(Window wf, Window wt)
*
* \param name the filename to expand
*/
char *
ExpandFilename(char *name)
const char *
ExpandFilename(const char *name)
{
char *newname;
if (name[0] != '~') return name;
newname = malloc (HomeLen + strlen(name) + 2);
newname = malloc(HomeLen + strlen(name) + 2);
if (!newname) {
fprintf (stderr,
"%s: unable to allocate %ld bytes to expand filename %s/%s\n",
ProgramName, HomeLen + (unsigned long)strlen(name) + 2,
Home, &name[1]);
fprintf(stderr,
"%s: unable to allocate %ld bytes to expand filename %s/%s\n",
ProgramName, HomeLen + (unsigned long)strlen(name) + 2,
Home, &name[1]);
} else {
(void) sprintf (newname, "%s/%s", Home, &name[1]);
(void) sprintf(newname, "%s/%s", Home, &name[1]);
}
return newname;
@ -341,7 +341,7 @@ FindBitmap (const char *name, unsigned *widthp, unsigned *heightp)
* are used. If the bigname is different from name, bigname will need to
* be freed.
*/
bigname = ExpandFilename (name);
bigname = (char*)ExpandFilename(name);
if (!bigname) return None;
/*
@ -598,7 +598,7 @@ GetFont(MyFont *font)
basename2 = malloc(strlen(font->name) + 3);
if (basename2) sprintf(basename2, "%s,*", font->name);
else basename2 = font->name;
else basename2 = (char*)font->name;
if( (font->fontset = XCreateFontSet(dpy, basename2,
&missing_charset_list_return,
&missing_charset_count_return,

View File

@ -64,7 +64,7 @@ in this Software without prior written authorization from The Open Group.
extern void MoveOutline ( Window root, int x, int y, int width, int height,
int bw, int th );
extern void Zoom ( Window wf, Window wt );
extern char * ExpandFilename ( char *name );
extern const char * ExpandFilename ( const char *name );
extern void GetUnknownIcon ( const char *name );
extern Pixmap FindBitmap ( const char *name, unsigned int *widthp,
unsigned int *heightp );