-
-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace use of dprintf() with fprintf() or write() #1912
Conversation
This improves compatibility with legacy platforms that don't provide the function, in particular, Illumos.
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the return value of write. CI fails with the following:
########## gcc-9 ##########
gcc-9 -Werror -std=c11 -Wall -Wextra -Wshadow -O3 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -o nnn src/nnn.c -lreadline -lncursesw -ltinfo -lpthread
src/nnn.c: In function 'write_lastdir':
src/nnn.c:2846:3: error: ignoring return value of 'write', declared with attribute warn_unused_result [-Werror=unused-result]
2846 | write(fd, "cd ", 3);
| ^~~~~~~~~~~~~~~~~~~
src/nnn.c:2847:3: error: ignoring return value of 'write', declared with attribute warn_unused_result [-Werror=unused-result]
2847 | write(fd, g_buf, strlen(g_buf));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:224: nnn] Error 1
Exited with code exit status 2
else | ||
bitmap[key] = TRUE; | ||
} | ||
} | ||
|
||
static void usage(void) | ||
{ | ||
dprintf(STDOUT_FILENO, | ||
printf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use fprintf().
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use fprintf().
Any update here? |
Merging. I'll take care of the rest. |
This improves compatibility with legacy platforms that don't provide the function, in particular, Illumos.
(Alternative to #1911)