Prefer fputs over fprintf where possible
fprintf does extra work and meant for formatting strings.
This commit is contained in:
@@ -109,7 +109,7 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
while (len <= maxlen) {
|
while (len <= maxlen) {
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
printf("# word wrap disabled\n");
|
puts("# word wrap disabled");
|
||||||
else
|
else
|
||||||
printf("# word wrap at %zu characters\n", len);
|
printf("# word wrap at %zu characters\n", len);
|
||||||
eventlog_writeln(stdout, lines[0], strlen(lines[0]), len);
|
eventlog_writeln(stdout, lines[0], strlen(lines[0]), len);
|
||||||
|
@@ -940,14 +940,14 @@ qprintf(const char *str, Char *s)
|
|||||||
|
|
||||||
(void)printf("%s:\n", str);
|
(void)printf("%s:\n", str);
|
||||||
for (p = s; *p; p++)
|
for (p = s; *p; p++)
|
||||||
(void)printf("%c", CHAR(*p));
|
(void)fputc(CHAR(*p), stdout);
|
||||||
(void)printf("\n");
|
(void)fputc('\n', stdout);
|
||||||
for (p = s; *p; p++)
|
for (p = s; *p; p++)
|
||||||
(void)printf("%c", *p & M_PROTECT ? '"' : ' ');
|
(void)fputc(*p & M_PROTECT ? '"' : ' ', stdout);
|
||||||
(void)printf("\n");
|
(void)fputc('\n', stdout);
|
||||||
for (p = s; *p; p++)
|
for (p = s; *p; p++)
|
||||||
(void)printf("%c", ismeta(*p) ? '_' : ' ');
|
(void)fputc(ismeta(*p) ? '_' : ' ', stdout);
|
||||||
(void)printf("\n");
|
(void)fputc('\n', stdout);
|
||||||
}
|
}
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
#endif /* HAVE_GLOB */
|
#endif /* HAVE_GLOB */
|
||||||
|
@@ -38,7 +38,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
#include "mksiglist.h"
|
#include "mksiglist.h"
|
||||||
|
|
||||||
printf("const char *const sudo_sys_siglist[] = {\n");
|
puts("const char *const sudo_sys_siglist[] = {");
|
||||||
for (i = 0; i < nitems(sudo_sys_siglist); i++) {
|
for (i = 0; i < nitems(sudo_sys_siglist); i++) {
|
||||||
if (sudo_sys_siglist[i] != NULL) {
|
if (sudo_sys_siglist[i] != NULL) {
|
||||||
printf(" \"%s\",\n", sudo_sys_siglist[i]);
|
printf(" \"%s\",\n", sudo_sys_siglist[i]);
|
||||||
@@ -46,7 +46,7 @@ main(int argc, char *argv[])
|
|||||||
printf(" \"Signal %zu\",\n", i);
|
printf(" \"Signal %zu\",\n", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("};\n");
|
puts("};");
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
#include "mksigname.h"
|
#include "mksigname.h"
|
||||||
|
|
||||||
printf("const char *const sudo_sys_signame[] = {\n");
|
puts("const char *const sudo_sys_signame[] = {");
|
||||||
for (i = 0; i < nitems(sudo_sys_signame); i++) {
|
for (i = 0; i < nitems(sudo_sys_signame); i++) {
|
||||||
if (sudo_sys_signame[i] != NULL) {
|
if (sudo_sys_signame[i] != NULL) {
|
||||||
printf(" \"%s\",\n", sudo_sys_signame[i]);
|
printf(" \"%s\",\n", sudo_sys_signame[i]);
|
||||||
@@ -46,7 +46,7 @@ main(int argc, char *argv[])
|
|||||||
printf(" \"Signal %zu\",\n", i);
|
printf(" \"Signal %zu\",\n", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("};\n");
|
puts("};");
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@@ -80,8 +80,7 @@ main(int argc, char **argv)
|
|||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
if (buf[len - 1] != '\n') {
|
if (buf[len - 1] != '\n') {
|
||||||
fprintf(stderr,
|
fputs("globtest: missing newline at EOF\n", stderr);
|
||||||
"globtest: missing newline at EOF\n");
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
buf[--len] = '\0';
|
buf[--len] = '\0';
|
||||||
|
@@ -1861,7 +1861,7 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (testrun)
|
if (testrun)
|
||||||
printf("sending logs...\n");
|
puts("sending logs...");
|
||||||
|
|
||||||
struct timespec t_start, t_end, t_result;
|
struct timespec t_start, t_end, t_result;
|
||||||
sudo_gettime_real(&t_start);
|
sudo_gettime_real(&t_start);
|
||||||
|
@@ -109,7 +109,7 @@ group_plugin_load(char *plugin_info)
|
|||||||
|
|
||||||
if (SUDO_API_VERSION_GET_MAJOR(group_plugin->version) != GROUP_API_VERSION_MAJOR) {
|
if (SUDO_API_VERSION_GET_MAJOR(group_plugin->version) != GROUP_API_VERSION_MAJOR) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: incompatible group plugin major version %u, expected %d\n",
|
"%s: incompatible group plugin major version %u, expected %u\n",
|
||||||
path, SUDO_API_VERSION_GET_MAJOR(group_plugin->version),
|
path, SUDO_API_VERSION_GET_MAJOR(group_plugin->version),
|
||||||
GROUP_API_VERSION_MAJOR);
|
GROUP_API_VERSION_MAJOR);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -171,15 +171,16 @@ group_plugin_query(const char *user, const char *group,
|
|||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fputs("usage: plugin_test [-p \"plugin.so plugin_args ...\"] user:group ...\n",
|
||||||
"usage: plugin_test [-p \"plugin.so plugin_args ...\"] user:group ...\n");
|
stderr);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ch, i, found;
|
int ch, found;
|
||||||
|
size_t i;
|
||||||
char *plugin = "group_file.so";
|
char *plugin = "group_file.so";
|
||||||
char *user, *group;
|
char *user, *group;
|
||||||
struct passwd *pwd;
|
struct passwd *pwd;
|
||||||
|
@@ -474,7 +474,7 @@ create_debug_config(const char *debug_spec)
|
|||||||
if (asprintf(&content, "Debug %s %s/debug.log %s\n",
|
if (asprintf(&content, "Debug %s %s/debug.log %s\n",
|
||||||
"python_plugin.so", data.tmp_dir, debug_spec) < 0)
|
"python_plugin.so", data.tmp_dir, debug_spec) < 0)
|
||||||
{
|
{
|
||||||
printf("Failed to allocate string\n");
|
puts("Failed to allocate string");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2440,15 +2440,14 @@ main(int argc, char *argv[])
|
|||||||
char buff[128];
|
char buff[128];
|
||||||
time_t d;
|
time_t d;
|
||||||
|
|
||||||
(void)printf("Enter date, or blank line to exit.\n\t> ");
|
(void)fputs("Enter date, or blank line to exit.\n\t> ", stdout);
|
||||||
(void)fflush(stdout);
|
(void)fflush(stdout);
|
||||||
while (fgets(buff, sizeof(buff), stdin) && buff[0]) {
|
while (fgets(buff, sizeof(buff), stdin) && buff[0]) {
|
||||||
d = get_date(buff);
|
d = get_date(buff);
|
||||||
if (d == -1)
|
if (d == -1)
|
||||||
(void)printf("Bad format - couldn't convert.\n");
|
(void)fputs("Bad format - couldn't convert.\n\t> ", stdout);
|
||||||
else
|
else
|
||||||
(void)printf("%s", ctime(&d));
|
(void)printf("%s\t> ", ctime(&d));
|
||||||
(void)printf("\t> ");
|
|
||||||
(void)fflush(stdout);
|
(void)fflush(stdout);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -906,15 +906,14 @@ main(int argc, char *argv[])
|
|||||||
char buff[128];
|
char buff[128];
|
||||||
time_t d;
|
time_t d;
|
||||||
|
|
||||||
(void)printf("Enter date, or blank line to exit.\n\t> ");
|
(void)fputs("Enter date, or blank line to exit.\n\t> ", stdout);
|
||||||
(void)fflush(stdout);
|
(void)fflush(stdout);
|
||||||
while (fgets(buff, sizeof(buff), stdin) && buff[0]) {
|
while (fgets(buff, sizeof(buff), stdin) && buff[0]) {
|
||||||
d = get_date(buff);
|
d = get_date(buff);
|
||||||
if (d == -1)
|
if (d == -1)
|
||||||
(void)printf("Bad format - couldn't convert.\n");
|
(void)fputs("Bad format - couldn't convert.\n\t> ", stdout);
|
||||||
else
|
else
|
||||||
(void)printf("%s", ctime(&d));
|
(void)printf("%s\t> ", ctime(&d));
|
||||||
(void)printf("\t> ");
|
|
||||||
(void)fflush(stdout);
|
(void)fflush(stdout);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -682,7 +682,7 @@ setup_terminal(struct eventlog *evlog, bool interactive, bool resize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (evlog->lines > terminal_lines || evlog->columns > terminal_cols) {
|
if (evlog->lines > terminal_lines || evlog->columns > terminal_cols) {
|
||||||
fputs(_("Warning: your terminal is too small to properly replay the log.\n"), stdout);
|
puts(_("Warning: your terminal is too small to properly replay the log."));
|
||||||
printf(_("Log geometry is %d x %d, your terminal's geometry is %d x %d."), evlog->lines, evlog->columns, terminal_lines, terminal_cols);
|
printf(_("Log geometry is %d x %d, your terminal's geometry is %d x %d."), evlog->lines, evlog->columns, terminal_lines, terminal_cols);
|
||||||
}
|
}
|
||||||
debug_return;
|
debug_return;
|
||||||
|
@@ -297,7 +297,7 @@ dump_entry(struct timestamp_entry *entry, off_t pos)
|
|||||||
} else if (entry->type == TS_PPID) {
|
} else if (entry->type == TS_PPID) {
|
||||||
printf("parent pid: %d\n", (int)entry->u.ppid);
|
printf("parent pid: %d\n", (int)entry->u.ppid);
|
||||||
}
|
}
|
||||||
printf("\n");
|
fputc('\n', stdout);
|
||||||
|
|
||||||
debug_return;
|
debug_return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user