remove bb_printf and the like
diff --git a/miscutils/crond.c b/miscutils/crond.c
index 4fc940b..b18e274 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -264,7 +264,7 @@
}
}
}
- bb_fflush_stdout_and_exit(EXIT_SUCCESS); /* not reached */
+ return 0; /* not reached */
}
static int ChangeUser(const char *user)
@@ -278,7 +278,7 @@
pas = getpwnam(user);
if (pas == 0) {
crondlog("\011failed to get uid for %s", user);
- return (-1);
+ return -1;
}
setenv("USER", pas->pw_name, 1);
setenv("HOME", pas->pw_dir, 1);
@@ -290,16 +290,16 @@
err_msg = change_identity_e2str(pas);
if (err_msg) {
crondlog("\011%s for user %s", err_msg, user);
- return (-1);
+ return -1;
}
if (chdir(pas->pw_dir) < 0) {
crondlog("\011chdir failed: %s: %m", pas->pw_dir);
if (chdir(TMPDIR) < 0) {
crondlog("\011chdir failed: %s: %m", TMPDIR);
- return (-1);
+ return -1;
}
}
- return (pas->pw_uid);
+ return pas->pw_uid;
}
static void startlogger(void)
@@ -377,7 +377,7 @@
int n2 = -1;
if (base == NULL) {
- return (NULL);
+ return NULL;
}
while (*ptr != ' ' && *ptr != '\t' && *ptr != '\n') {
@@ -420,7 +420,7 @@
if (skip == 0) {
crondlog("\111failed user %s parsing %s\n", user, base);
- return (NULL);
+ return NULL;
}
if (*ptr == '-' && n2 < 0) {
++ptr;
@@ -460,7 +460,7 @@
if (failsafe == 0) {
crondlog("\111failed user %s parsing %s\n", user, base);
- return (NULL);
+ return NULL;
}
}
if (*ptr != ',') {
@@ -473,7 +473,7 @@
if (*ptr != ' ' && *ptr != '\t' && *ptr != '\n') {
crondlog("\111failed user %s parsing %s\n", user, base);
- return (NULL);
+ return NULL;
}
while (*ptr == ' ' || *ptr == '\t' || *ptr == '\n') {
@@ -490,7 +490,7 @@
}
#endif
- return (ptr);
+ return ptr;
}
static void FixDayDow(CronLine * line)
@@ -777,7 +777,7 @@
}
}
}
- return (nJobs);
+ return nJobs;
}
static void RunJobs(void)
@@ -843,7 +843,7 @@
}
nStillRunning += file->cf_Running;
}
- return (nStillRunning);
+ return nStillRunning;
}
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c
index f1fee2c..32973d6 100644
--- a/miscutils/devfsd.c
+++ b/miscutils/devfsd.c
@@ -491,9 +491,9 @@
if ( print_version || (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev) )
{
- bb_printf( "%s v%s\nDaemon %s:\t%d\nKernel-side %s:\t%d\n",
- applet_name,DEVFSD_VERSION,bb_msg_proto_rev,
- DEVFSD_PROTOCOL_REVISION_DAEMON,bb_msg_proto_rev, proto_rev);
+ printf( "%s v%s\nDaemon %s:\t%d\nKernel-side %s:\t%d\n",
+ applet_name,DEVFSD_VERSION,bb_msg_proto_rev,
+ DEVFSD_PROTOCOL_REVISION_DAEMON,bb_msg_proto_rev, proto_rev);
if (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev)
bb_error_msg_and_die( "%s mismatch!",bb_msg_proto_rev);
exit(EXIT_SUCCESS); /* -v */
@@ -509,7 +509,7 @@
if (sigaction (SIGHUP, &new_action, NULL) != 0 || sigaction (SIGUSR1, &new_action, NULL) != 0 )
devfsd_error_msg_and_die( "sigaction");
- bb_printf("%s v%s started for %s\n",applet_name, DEVFSD_VERSION, mount_point);
+ printf("%s v%s started for %s\n",applet_name, DEVFSD_VERSION, mount_point);
/* Set umask so that mknod(2), open(2) and mkdir(2) have complete control over permissions */
umask (0);
diff --git a/miscutils/last.c b/miscutils/last.c
index 9f9f639..668f0c1 100644
--- a/miscutils/last.c
+++ b/miscutils/last.c
@@ -87,5 +87,5 @@
ctime(&t_tmp) + 4);
}
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
diff --git a/miscutils/less.c b/miscutils/less.c
index 11f1d8b..de97ba6 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -76,7 +76,7 @@
static int past_eof;
/* Command line options */
-static unsigned long flags;
+static unsigned flags;
#define FLAG_E 1
#define FLAG_M (1<<1)
#define FLAG_m (1<<2)
@@ -185,12 +185,12 @@
/* This adds line numbers to every line, as the -N flag necessitates */
static void add_linenumbers(void)
{
- char current_line[256];
int i;
for (i = 0; i <= num_flines; i++) {
- safe_strncpy(current_line, flines[i], 256);
- flines[i] = xasprintf("%5d %s", i + 1, current_line);
+ char *new = xasprintf("%5d %s", i + 1, flines[i]);
+ free(flines[i]);
+ flines[i] = new;
}
}
@@ -206,7 +206,7 @@
strcpy(current_line, "");
fgets(current_line, 256, fp);
if (fp != stdin)
- xferror(fp, filename);
+ die_if_ferror(fp, filename);
flines = xrealloc(flines, (i+1) * sizeof(char *));
flines[i] = xstrdup(current_line);
}
@@ -243,13 +243,18 @@
if (!past_eof) {
if (!line_pos) {
if (num_files > 1)
- printf("%s%s %s%i%s%i%s%i-%i/%i ", HIGHLIGHT, filename, "(file ", current_file, " of ", num_files, ") lines ", line_pos + 1, line_pos + height - 1, num_flines + 1);
+ printf("%s%s %s%i%s%i%s%i-%i/%i ", HIGHLIGHT,
+ filename, "(file ", current_file, " of ", num_files, ") lines ",
+ line_pos + 1, line_pos + height - 1, num_flines + 1);
else {
- printf("%s%s lines %i-%i/%i ", HIGHLIGHT, filename, line_pos + 1, line_pos + height - 1, num_flines + 1);
+ printf("%s%s lines %i-%i/%i ", HIGHLIGHT,
+ filename, line_pos + 1, line_pos + height - 1,
+ num_flines + 1);
}
}
else {
- printf("%s %s lines %i-%i/%i ", HIGHLIGHT, filename, line_pos + 1, line_pos + height - 1, num_flines + 1);
+ printf("%s %s lines %i-%i/%i ", HIGHLIGHT, filename,
+ line_pos + 1, line_pos + height - 1, num_flines + 1);
}
if (line_pos == num_flines - height + 2) {
@@ -263,7 +268,8 @@
}
}
else {
- printf("%s%s lines %i-%i/%i (END) ", HIGHLIGHT, filename, line_pos + 1, num_flines + 1, num_flines + 1);
+ printf("%s%s lines %i-%i/%i (END) ", HIGHLIGHT, filename,
+ line_pos + 1, num_flines + 1, num_flines + 1);
if ((num_files > 1) && (current_file != num_files))
printf("- Next: %s", files[current_file]);
printf("%s", NORMAL);
@@ -300,7 +306,8 @@
if (!line_pos) {
printf("%s%s %s", HIGHLIGHT, filename, NORMAL);
if (num_files > 1)
- printf("%s%s%i%s%i%s%s", HIGHLIGHT, "(file ", current_file, " of ", num_files, ")", NORMAL);
+ printf("%s%s%i%s%i%s%s", HIGHLIGHT, "(file ",
+ current_file, " of ", num_files, ")", NORMAL);
}
else if (line_pos == num_flines - height + 2) {
printf("%s%s %s", HIGHLIGHT, "(END)", NORMAL);
@@ -602,7 +609,7 @@
insert_highlights if action = 1, or has the escape sequences
removed if action = 0, and then the line is returned. */
int match_status;
- char *line2 = (char *) xmalloc((sizeof(char) * (strlen(line) + 1)) + 64);
+ char *line2 = xmalloc((sizeof(char) * (strlen(line) + 1)) + 64);
char *growline = "";
regmatch_t match_structs;
@@ -616,10 +623,16 @@
match_found = 1;
if (action) {
- growline = xasprintf("%s%.*s%s%.*s%s", growline, match_structs.rm_so, line2, HIGHLIGHT, match_structs.rm_eo - match_structs.rm_so, line2 + match_structs.rm_so, NORMAL);
+ growline = xasprintf("%s%.*s%s%.*s%s", growline,
+ match_structs.rm_so, line2, HIGHLIGHT,
+ match_structs.rm_eo - match_structs.rm_so,
+ line2 + match_structs.rm_so, NORMAL);
}
else {
- growline = xasprintf("%s%.*s%.*s", growline, match_structs.rm_so - 4, line2, match_structs.rm_eo - match_structs.rm_so, line2 + match_structs.rm_so);
+ growline = xasprintf("%s%.*s%.*s", growline,
+ match_structs.rm_so - 4, line2,
+ match_structs.rm_eo - match_structs.rm_so,
+ line2 + match_structs.rm_so);
}
line2 += match_structs.rm_eo;
diff --git a/miscutils/mountpoint.c b/miscutils/mountpoint.c
index dbc8fe0..b1bcab6 100644
--- a/miscutils/mountpoint.c
+++ b/miscutils/mountpoint.c
@@ -13,6 +13,8 @@
int mountpoint_main(int argc, char **argv)
{
+ struct stat st;
+ char *arg;
int opt = getopt32(argc, argv, "qdx");
#define OPT_q (1)
#define OPT_d (2)
@@ -20,47 +22,44 @@
if (optind != argc - 1)
bb_show_usage();
- {
- char *arg = argv[optind];
- struct stat st;
- if ( (opt & OPT_x && stat(arg, &st) == 0) || (lstat(arg, &st) == 0) ) {
- if (opt & OPT_x) {
- if (S_ISBLK(st.st_mode))
- {
- bb_printf("%u:%u\n", major(st.st_rdev),
- minor(st.st_rdev));
- return EXIT_SUCCESS;
- } else {
- if (opt & OPT_q)
- putchar('\n');
- else
- bb_error_msg("%s: not a block device", arg);
- }
- return EXIT_FAILURE;
- } else
- if (S_ISDIR(st.st_mode)) {
- dev_t st_dev = st.st_dev;
- ino_t st_ino = st.st_ino;
- char *p = xasprintf("%s/..", arg);
+ arg = argv[optind];
- if (stat(p, &st) == 0) {
- short ret = (st_dev != st.st_dev) ||
- (st_dev == st.st_dev && st_ino == st.st_ino);
- if (opt & OPT_d)
- bb_printf("%u:%u\n", major(st_dev), minor(st_dev));
- else if (!(opt & OPT_q))
- bb_printf("%s is %sa mountpoint\n", arg, ret?"":"not ");
- return !ret;
- }
+ if ( (opt & OPT_x && stat(arg, &st) == 0) || (lstat(arg, &st) == 0) ) {
+ if (opt & OPT_x) {
+ if (S_ISBLK(st.st_mode)) {
+ printf("%u:%u\n", major(st.st_rdev),
+ minor(st.st_rdev));
+ return EXIT_SUCCESS;
} else {
- if (!(opt & OPT_q))
- bb_error_msg("%s: not a directory", arg);
- return EXIT_FAILURE;
+ if (opt & OPT_q)
+ putchar('\n');
+ else
+ bb_error_msg("%s: not a block device", arg);
}
+ return EXIT_FAILURE;
+ } else
+ if (S_ISDIR(st.st_mode)) {
+ dev_t st_dev = st.st_dev;
+ ino_t st_ino = st.st_ino;
+ char *p = xasprintf("%s/..", arg);
+
+ if (stat(p, &st) == 0) {
+ int ret = (st_dev != st.st_dev) ||
+ (st_dev == st.st_dev && st_ino == st.st_ino);
+ if (opt & OPT_d)
+ printf("%u:%u\n", major(st_dev), minor(st_dev));
+ else if (!(opt & OPT_q))
+ printf("%s is %sa mountpoint\n", arg, ret?"":"not ");
+ return !ret;
+ }
+ } else {
+ if (!(opt & OPT_q))
+ bb_error_msg("%s: not a directory", arg);
+ return EXIT_FAILURE;
}
- if (!(opt & OPT_q))
- bb_perror_msg("%s", arg);
- return EXIT_FAILURE;
}
+ if (!(opt & OPT_q))
+ bb_perror_msg("%s", arg);
+ return EXIT_FAILURE;
}
diff --git a/miscutils/rx.c b/miscutils/rx.c
index 00951b7..f723c16 100644
--- a/miscutils/rx.c
+++ b/miscutils/rx.c
@@ -286,5 +286,5 @@
if (n < 0)
bb_error_msg_and_die("\nreceive failed:\n %s", error_buf);
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
diff --git a/miscutils/strings.c b/miscutils/strings.c
index 1ff41ad..dae1731 100644
--- a/miscutils/strings.c
+++ b/miscutils/strings.c
@@ -84,5 +84,5 @@
if (ENABLE_FEATURE_CLEAN_UP)
free(string);
- bb_fflush_stdout_and_exit(status);
+ fflush_stdout_and_exit(status);
}