Skip to content

Commit

Permalink
Replace use of dprintf() with fprintf() or write()
Browse files Browse the repository at this point in the history
This improves compatibility with legacy platforms that don't provide the
function, in particular, Illumos.
  • Loading branch information
sjmulder committed Jul 16, 2024
1 parent 86d883e commit 26e85fc
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/nnn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ static int create_tmp_file(void)

static void msg(const char *message)
{
dprintf(STDERR_FILENO, "%s\n", message);
fprintf(stderr, "%s\n", message);
}

#ifdef KEY_RESIZE
Expand Down Expand Up @@ -2843,7 +2843,8 @@ static void write_lastdir(const char *curpath, const char *outfile)
: cfgpath, O_CREAT | O_WRONLY | O_TRUNC, S_IWUSR | S_IRUSR);

if (fd != -1 && shell_escape(g_buf, sizeof(g_buf), curpath)) {
dprintf(fd, "cd %s", g_buf);
write(fd, "cd ", 3);
write(fd, g_buf, strlen(g_buf));

Check warning

Code scanning / CodeQL

Exposure of system data to an unauthorized control sphere Medium

This operation exposes system data from
*call to getenv
.
This operation exposes system data from
*call to getenv
.
close(fd);
}
}
Expand Down Expand Up @@ -8357,15 +8358,15 @@ static void check_key_collision(void)
key = bindings[i].sym;

if (bitmap[key])
dprintf(STDERR_FILENO, "key collision! [%s]\n", keyname(key));
fprintf(stderr, "key collision! [%s]\n", keyname(key));
else
bitmap[key] = TRUE;
}
}

static void usage(void)
{
dprintf(STDOUT_FILENO,
printf(
"%s: nnn [OPTIONS] [PATH]\n\n"
"The unorthodox terminal file manager.\n\n"
"positional args:\n"
Expand Down Expand Up @@ -8716,7 +8717,7 @@ int main(int argc, char *argv[])
g_state.uidgid = 1;
break;
case 'V':
dprintf(STDOUT_FILENO, "%s\n", VERSION);
printf("%s\n", VERSION);
return EXIT_SUCCESS;
case 'x':
cfg.x11 = 1;
Expand Down

0 comments on commit 26e85fc

Please sign in to comment.