All file descriptors variables now begin with `fd`.
if (pid == 0)
{
mutt_sig_unblock_system(false);
- const int devnull = open("/dev/null", O_RDWR);
- if ((devnull < 0) || (dup2(pout[0], STDIN_FILENO) < 0) ||
- (dup2(pin[1], STDOUT_FILENO) < 0) || (dup2(devnull, STDERR_FILENO) < 0))
+ const int fd_null = open("/dev/null", O_RDWR);
+ if ((fd_null < 0) || (dup2(pout[0], STDIN_FILENO) < 0) ||
+ (dup2(pin[1], STDOUT_FILENO) < 0) || (dup2(fd_null, STDERR_FILENO) < 0))
{
_exit(127);
}
close(pin[1]);
close(pout[0]);
close(pout[1]);
- close(devnull);
+ close(fd_null);
/* Don't let the subprocess think it can use the controlling tty */
setsid();
{
struct termios t;
struct termios old;
- int f, ch;
- f = open("/dev/tty", O_RDONLY);
- if (f < 0)
+ int fd = open("/dev/tty", O_RDONLY);
+ if (fd < 0)
return EOF;
- tcgetattr(f, &t);
+ tcgetattr(fd, &t);
memcpy((void *) &old, (void *) &t, sizeof(struct termios)); /* save original state */
t.c_lflag &= ~(ICANON | ECHO);
t.c_cc[VMIN] = 1;
t.c_cc[VTIME] = 0;
- tcsetattr(f, TCSADRAIN, &t);
+ tcsetattr(fd, TCSADRAIN, &t);
fflush(stdout);
if (s)
fputs(s, stdout);
else
fputs(_("Press any key to continue..."), stdout);
fflush(stdout);
- ch = fgetc(stdin);
+ int ch = fgetc(stdin);
fflush(stdin);
- tcsetattr(f, TCSADRAIN, &old);
- close(f);
+ tcsetattr(fd, TCSADRAIN, &old);
+ close(fd);
fputs("\r\n", stdout);
mutt_clear_error();
return (ch >= 0) ? ch : EOF;
/* Create a temporary file to write the new version of the mailbox in. */
mutt_mktemp(tempfile, sizeof(tempfile));
- i = open(tempfile, O_WRONLY | O_EXCL | O_CREAT, 0600);
- if ((i == -1) || !(fp = fdopen(i, "w")))
+ int fd = open(tempfile, O_WRONLY | O_EXCL | O_CREAT, 0600);
+ if ((fd == -1) || !(fp = fdopen(fd, "w")))
{
- if (-1 != i)
+ if (fd != -1)
{
- close(i);
+ close(fd);
unlink(tempfile);
}
mutt_error(_("Could not create temporary file"));
*/
void mutt_file_unlink_empty(const char *path)
{
- int fd;
struct stat sb;
- fd = open(path, O_RDWR);
+ int fd = open(path, O_RDWR);
if (fd == -1)
return;
if (use_mailcap)
{
pid_t pid = 0;
- int tempfd = -1, pagerfd = -1;
+ int fd_temp = -1, fd_pager = -1;
if (!use_pager)
mutt_endwin();
if (use_pager || use_pipe)
{
if (use_pager &&
- ((pagerfd = mutt_file_open(pagerfile, O_CREAT | O_EXCL | O_WRONLY)) == -1))
+ ((fd_pager = mutt_file_open(pagerfile, O_CREAT | O_EXCL | O_WRONLY)) == -1))
{
mutt_perror("open");
goto return_error;
}
- if (use_pipe && ((tempfd = open(tempfile, 0)) == -1))
+ if (use_pipe && ((fd_temp = open(tempfile, 0)) == -1))
{
- if (pagerfd != -1)
- close(pagerfd);
+ if (fd_pager != -1)
+ close(fd_pager);
mutt_perror("open");
goto return_error;
}
- pid = mutt_create_filter_fd(cmd, NULL, NULL, NULL, use_pipe ? tempfd : -1,
- use_pager ? pagerfd : -1, -1);
+ pid = mutt_create_filter_fd(cmd, NULL, NULL, NULL, use_pipe ? fd_temp : -1,
+ use_pager ? fd_pager : -1, -1);
if (pid == -1)
{
- if (pagerfd != -1)
- close(pagerfd);
+ if (fd_pager != -1)
+ close(fd_pager);
- if (tempfd != -1)
- close(tempfd);
+ if (fd_temp != -1)
+ close(fd_temp);
mutt_error(_("Can't create filter"));
goto return_error;
if ((mutt_wait_filter(pid) || (entry->needsterminal && C_WaitKey)) && !use_pager)
mutt_any_key_to_continue(NULL);
- if (tempfd != -1)
- close(tempfd);
- if (pagerfd != -1)
- close(pagerfd);
+ if (fd_temp != -1)
+ close(fd_temp);
+ if (fd_pager != -1)
+ close(fd_pager);
}
else
{
char buf[1024];
struct PgpKeyInfo *db = NULL, **kend = NULL, *k = NULL, *kk = NULL, *mainkey = NULL;
bool is_sub = false;
- int devnull;
- devnull = open("/dev/null", O_RDWR);
- if (devnull == -1)
+ int fd_null = open("/dev/null", O_RDWR);
+ if (fd_null == -1)
return NULL;
mutt_str_replace(&chs, C_Charset);
- pid = pgp_invoke_list_keys(NULL, &fp, NULL, -1, -1, devnull, keyring, hints);
+ pid = pgp_invoke_list_keys(NULL, &fp, NULL, -1, -1, fd_null, keyring, hints);
if (pid == -1)
{
- close(devnull);
+ close(fd_null);
return NULL;
}
mutt_file_fclose(&fp);
mutt_wait_filter(pid);
- close(devnull);
+ close(fd_null);
return db;
}
char buf[PATH_MAX];
char tmp[1024];
char cmd[STR_COMMAND];
- int devnull;
char *personal = NULL;
mutt_pgp_command(cmd, sizeof(cmd), &cctx, C_PgpGetkeysCommand);
- devnull = open("/dev/null", O_RDWR);
+ int fd_null = open("/dev/null", O_RDWR);
if (!isendwin())
mutt_message(_("Fetching PGP key..."));
if (!isendwin())
mutt_clear_error();
- if (devnull >= 0)
- close(devnull);
+ if (fd_null >= 0)
+ close(fd_null);
}
/**
{
FILE *fp = NULL;
pid_t mm_pid;
- int devnull;
char cmd[STR_COMMAND];
char line[8192];
if (!l)
return NULL;
- devnull = open("/dev/null", O_RDWR);
- if (devnull == -1)
+ int fd_null = open("/dev/null", O_RDWR);
+ if (fd_null == -1)
return NULL;
snprintf(cmd, sizeof(cmd), "%s -T", C_Mixmaster);
- mm_pid = mutt_create_filter_fd(cmd, NULL, &fp, NULL, devnull, -1, devnull);
+ mm_pid = mutt_create_filter_fd(cmd, NULL, &fp, NULL, fd_null, -1, fd_null);
if (mm_pid == -1)
{
- close(devnull);
+ close(fd_null);
return NULL;
}
mix_add_entry(&type2_list, NULL, &slots, &used);
mutt_wait_filter(mm_pid);
- close(devnull);
+ close(fd_null);
return type2_list;
}