aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2016-08-20 21:39:47 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2016-08-20 21:39:47 +0530
commit8cb25227b3aa2ddab1f861014e11c93ccf87355e (patch)
treea4f9a77c43267b36f1152e80066af229f739290a
parentbc731cd9c057c03a1ceaab61fd513b67d2d4c9a9 (diff)
downloadnnn-8cb25227b3aa2ddab1f861014e11c93ccf87355e.tar.gz
Fix compilation issues with -O3 optimization.
-rw-r--r--noice.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/noice.c b/noice.c
index 4db6f7f..9e679a8 100644
--- a/noice.c
+++ b/noice.c
@@ -118,7 +118,7 @@ dprintf(int fd, const char *fmt, ...)
va_start(ap, fmt);
r = vsnprintf(buf, sizeof(buf), fmt, ap);
if (r > 0)
- write(fd, buf, r);
+ r = write(fd, buf, r);
va_end(ap);
return r;
}
@@ -179,7 +179,7 @@ spawn(char *file, char *arg, char *dir)
pid = fork();
if (pid == 0) {
if (dir != NULL)
- chdir(dir);
+ status = chdir(dir);
execlp(file, file, arg, NULL);
_exit(1);
} else {
@@ -218,7 +218,6 @@ openwith(char *file)
DPRINTF_S(mime);
if (strcmp(mime, "text/plain") == 0)
- magic_close(magic);
return "vim";
magic_close(magic);
@@ -566,7 +565,10 @@ redraw(char *path)
ncols = PATH_MAX;
strlcpy(cwd, path, ncols);
cwd[ncols - strlen(CWD) - 1] = '\0';
- realpath(cwd, cwdresolved);
+ if (!realpath(cwd, cwdresolved)) {
+ printmsg("Cannot resolve path");
+ return;
+ }
printw(CWD "%s\n\n", cwdresolved);
@@ -665,11 +667,11 @@ nochange:
case S_IFREG:
bin = openwith(newpath);
if (bin == NULL) {
- char cmd[512];
- sprintf(cmd, "xdg-open \"%s\" > /dev/null 2>&1", newpath);
- system(cmd);
- printmsg("No association");
- goto nochange;
+ char cmd[512];
+ int status;
+ sprintf(cmd, "xdg-open \"%s\" > /dev/null 2>&1", newpath);
+ status = system(cmd);
+ continue;
}
exitcurses();
spawn(bin, newpath, NULL);