From e507de959e3e615c81782a6b982c1b70b5978995 Mon Sep 17 00:00:00 2001 From: Peter Howkins Date: Fri, 30 Mar 2018 20:24:04 +0100 Subject: [PATCH] dtcalc: resolve coverity issues --- cde/programs/dtcalc/ds_xlib.c | 15 +++++---------- cde/programs/dtcalc/motif.c | 4 ++-- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/cde/programs/dtcalc/ds_xlib.c b/cde/programs/dtcalc/ds_xlib.c index 2e13a0d2..a9489804 100644 --- a/cde/programs/dtcalc/ds_xlib.c +++ b/cde/programs/dtcalc/ds_xlib.c @@ -44,11 +44,6 @@ #include #include -#define FREE (void) free -#define FPRINTF (void) fprintf -#define GETHOSTNAME (void) gethostname -#define SPRINTF (void) sprintf -#define STRCPY (void) strcpy #define EQUAL(a, b) !strncmp(a, b, strlen(b)) #define MAXLINE 120 /* Maximum length for character strings. */ @@ -153,7 +148,7 @@ ds_load_resources(Display *display) db = XrmGetStringDatabase(XResourceManagerString(display)) ; else { - SPRINTF(name, "%s/.Xdefaults", home) ; + snprintf(name, sizeof(name), "%s/.Xdefaults", home) ; db = XrmGetFileDatabase(name) ; } XrmMergeDatabases(db, &rDB) ; @@ -166,7 +161,7 @@ ds_load_resources(Display *display) { snprintf(name, sizeof(name), "%s/.Xdefaults-", home) ; len = strlen(name) ; - GETHOSTNAME(name+len, 1024-len) ; + gethostname(name+len, 1024-len) ; db = XrmGetFileDatabase(name) ; } else db = XrmGetFileDatabase(ptr) ; @@ -267,7 +262,7 @@ ds_save_resources(XrmDatabase rDB, char *filename) { home = getenv("HOME") ; filename = (char*) calloc(1, strlen(home) + 18) ; - SPRINTF(filename, "%s/.dtcalcdef", home) ; + snprintf(filename, sizeof(filename), "%s/.dtcalcdef", home) ; } } @@ -275,14 +270,14 @@ ds_save_resources(XrmDatabase rDB, char *filename) if (stat(filename, &statbuf) != -1 && access(filename, W_OK) != 0) { - FREE(filename) ; + free(filename) ; return(1) ; } /* If file does not exist this call will create it. */ XrmPutFileDatabase(rDB, filename) ; - FREE(filename) ; + free(filename) ; return(0) ; } diff --git a/cde/programs/dtcalc/motif.c b/cde/programs/dtcalc/motif.c index 042af244..e828c665 100644 --- a/cde/programs/dtcalc/motif.c +++ b/cde/programs/dtcalc/motif.c @@ -1984,8 +1984,8 @@ get_next_event(Widget widget, int ev_action, XEvent *xevent) else if (ksym == XK_Meta_R && down) return(META); else if (ksym == XK_Meta_R && up) return(META); else if (ksym == XK_Alt_L && down) return(ALT); - else if (ksym == XK_Alt_R && up) return(ALT); - else if (ksym == XK_Alt_L && down) return(ALT); + else if (ksym == XK_Alt_L && up) return(ALT); + else if (ksym == XK_Alt_R && down) return(ALT); else if (ksym == XK_Alt_R && up) return(ALT); else if (ksym == XK_Select && down) return(SPACE); else if (ksym == XK_Select && up) return(SPACE); -- 2.25.1