summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Klausner <wiz@NetBSD.org>2015-09-23 20:53:24 +0200
committerThomas Klausner <wiz@NetBSD.org>2015-09-28 09:45:59 +0200
commitc5abcb619eb0b01f074fd9acb9128f19af774834 (patch)
tree3b33a2b3674e9a9b1b816fcab0cb23343bfd9545 /src
parentcb5dc44303e8496450a649a97540e55887e1fe22 (diff)
Adapt callers to ExpandFilename change.
It now always allocates memory, so remove some unnecessary checks. While here, improve handling of an error case. Signed-off-by: Thomas Klausner <wiz@NetBSD.org> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src')
-rw-r--r--src/menus.c32
-rw-r--r--src/util.c4
2 files changed, 20 insertions, 16 deletions
diff --git a/src/menus.c b/src/menus.c
index e23b5ff..ada9c41 100644
--- a/src/menus.c
+++ b/src/menus.c
@@ -2020,7 +2020,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
"%s: unable to open cut file \"%s\"\n",
ProgramName, tmp);
}
- if (ptr != tmp) free (ptr);
+ free (ptr);
}
} else {
XFree(ptr);
@@ -2171,21 +2171,25 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
case F_FILE:
ptr = ExpandFilename(action);
- fd = open(ptr, O_RDONLY);
- if (fd >= 0)
- {
- count = read(fd, buff, MAX_FILE_SIZE - 1);
- if (count > 0)
- XStoreBytes(dpy, buff, count);
+ if (ptr) {
+ fd = open(ptr, O_RDONLY);
+ if (fd >= 0)
+ {
+ count = read(fd, buff, MAX_FILE_SIZE - 1);
+ if (count > 0)
+ XStoreBytes(dpy, buff, count);
- close(fd);
- }
- else
- {
- fprintf (stderr, "%s: unable to open file \"%s\"\n",
- ProgramName, ptr);
+ close(fd);
+ }
+ else
+ {
+ fprintf (stderr, "%s: unable to open file \"%s\"\n",
+ ProgramName, ptr);
+ }
+ free(ptr);
+ } else {
+ fprintf (stderr, "%s: error expanding filename\n", ProgramName);
}
- if (ptr != action) free(ptr);
break;
case F_REFRESH:
diff --git a/src/util.c b/src/util.c
index 5e8f0db..8e9dab9 100644
--- a/src/util.c
+++ b/src/util.c
@@ -350,7 +350,7 @@ FindBitmap (const char *name, unsigned *widthp, unsigned *heightp)
pm = XmuLocateBitmapFile (ScreenOfDisplay(dpy, Scr->screen), bigname, NULL,
0, (int *)widthp, (int *)heightp, &HotX, &HotY);
if (pm == None && Scr->IconDirectory && bigname[0] != '/') {
- if (bigname != name) free (bigname);
+ free (bigname);
/*
* Attempt to find icon in old IconDirectory (now obsolete)
*/
@@ -367,7 +367,7 @@ FindBitmap (const char *name, unsigned *widthp, unsigned *heightp)
pm = None;
}
}
- if (bigname != name) free (bigname);
+ free (bigname);
if (pm == None) {
fprintf (stderr, "%s: unable to find bitmap \"%s\"\n",
ProgramName, name);