From e380805990816e191aa75cd9fb791b1c2b36ceee Mon Sep 17 00:00:00 2001 From: Yorhel <git@yorhel.nl> Date: Sun, 26 Aug 2012 18:08:56 +0200 Subject: [PATCH] Fixed some compiler warnings and a (rather nonexistent) memory leak This silences clang and gcc with -O2 -Wall -Wextra --- src/browser.c | 2 +- src/dir_common.c | 4 ++-- src/dir_scan.c | 4 +++- src/path.c | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/browser.c b/src/browser.c index d13dac8..3a84d9f 100644 --- a/src/browser.c +++ b/src/browser.c @@ -152,7 +152,7 @@ static void browse_draw_item(struct dir *n, int row) { void browse_draw() { struct dir *t; char fmtsize[9], *tmp; - int selected, i; + int selected = 0, i; erase(); t = dirlist_get(0); diff --git a/src/dir_common.c b/src/dir_common.c index c4ff819..fecaa23 100644 --- a/src/dir_common.c +++ b/src/dir_common.c @@ -119,9 +119,9 @@ struct dir *dir_createstruct(const char *name) { static void draw_progress() { static const char antext[] = "Scanning..."; - static int anpos = 0; + static size_t anpos = 0; char ani[20] = {}; - int i; + size_t i; int width = wincols-5; nccreate(10, width, "Scanning..."); diff --git a/src/dir_scan.c b/src/dir_scan.c index a511275..e7ee5d8 100644 --- a/src/dir_scan.c +++ b/src/dir_scan.c @@ -248,8 +248,10 @@ int dir_scan_process() { dir_seterr("Error reading directory: %s", strerror(errno)); /* Special case: empty directory = error */ - if(!dir_fatalerr && !*dir) + if(!dir_fatalerr && !*dir) { dir_seterr("Directory empty"); + free(dir); + } if(!dir_fatalerr) { curdev = fs.st_dev; diff --git a/src/path.c b/src/path.c index 17b1e39..1c6c587 100644 --- a/src/path.c +++ b/src/path.c @@ -127,7 +127,7 @@ static char *path_absolute(const char *path) { /* NOTE: cwd and the memory cur points to are unreliable after calling this function */ static char *path_real_rec(char *cur, int *links) { int i, n, tmpl, lnkl = 0; - char **arr, *tmp, *lnk, *ret = NULL; + char **arr, *tmp, *lnk = NULL, *ret = NULL; tmpl = strlen(cur)+1; tmp = malloc(tmpl); -- GitLab