mostly style fixes

This commit is contained in:
Denis Vlasenko 2006-11-01 10:25:35 +00:00
parent 048c93cc55
commit 9225854144
12 changed files with 156 additions and 161 deletions

View File

@ -56,20 +56,20 @@ typedef int (*action_fp)(const char *fileName, struct stat *statbuf, void *);
typedef struct {
action_fp f;
} action;
#define SACT(name, arg...) typedef struct { action a; arg; } action_##name;
#define SFUNC(name) static int func_##name(const char *fileName, struct stat *statbuf, action_##name* ap)
SACT(print)
SACT(name, char *pattern;)
USE_FEATURE_FIND_PRINT0(SACT(print0))
USE_FEATURE_FIND_TYPE( SACT(type, int type_mask;))
USE_FEATURE_FIND_PERM( SACT(perm, char perm_char; int perm_mask;))
USE_FEATURE_FIND_MTIME( SACT(mtime, char mtime_char; int mtime_days;))
USE_FEATURE_FIND_MMIN( SACT(mmin, char mmin_char; int mmin_mins;))
USE_FEATURE_FIND_NEWER( SACT(newer, time_t newer_mtime;))
USE_FEATURE_FIND_INUM( SACT(inum, ino_t inode_num;))
USE_FEATURE_FIND_EXEC( SACT(exec, char **exec_argv; int *subst_count; int exec_argc;))
USE_DESKTOP( SACT(paren, action ***subexpr;))
USE_DESKTOP( SACT(prune))
#define ACTS(name, arg...) typedef struct { action a; arg; } action_##name;
#define ACTF(name) static int func_##name(const char *fileName, struct stat *statbuf, action_##name* ap)
ACTS(print)
ACTS(name, char *pattern;)
USE_FEATURE_FIND_PRINT0(ACTS(print0))
USE_FEATURE_FIND_TYPE( ACTS(type, int type_mask;))
USE_FEATURE_FIND_PERM( ACTS(perm, char perm_char; int perm_mask;))
USE_FEATURE_FIND_MTIME( ACTS(mtime, char mtime_char; int mtime_days;))
USE_FEATURE_FIND_MMIN( ACTS(mmin, char mmin_char; int mmin_mins;))
USE_FEATURE_FIND_NEWER( ACTS(newer, time_t newer_mtime;))
USE_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;))
USE_FEATURE_FIND_EXEC( ACTS(exec, char **exec_argv; int *subst_count; int exec_argc;))
USE_DESKTOP( ACTS(paren, action ***subexpr;))
USE_DESKTOP( ACTS(prune))
static action ***actions;
static int need_print = 1;
@ -131,7 +131,7 @@ static int exec_actions(action ***appp, const char *fileName, struct stat *statb
}
SFUNC(name)
ACTF(name)
{
const char *tmp = strrchr(fileName, '/');
if (tmp == NULL)
@ -141,13 +141,13 @@ SFUNC(name)
return fnmatch(ap->pattern, tmp, FNM_PERIOD) == 0;
}
#if ENABLE_FEATURE_FIND_TYPE
SFUNC(type)
ACTF(type)
{
return ((statbuf->st_mode & S_IFMT) == ap->type_mask);
}
#endif
#if ENABLE_FEATURE_FIND_PERM
SFUNC(perm)
ACTF(perm)
{
return !((isdigit(ap->perm_char) && (statbuf->st_mode & 07777) == ap->perm_mask)
|| (ap->perm_char == '-' && (statbuf->st_mode & ap->perm_mask) == ap->perm_mask)
@ -155,7 +155,7 @@ SFUNC(perm)
}
#endif
#if ENABLE_FEATURE_FIND_MTIME
SFUNC(mtime)
ACTF(mtime)
{
time_t file_age = time(NULL) - statbuf->st_mtime;
time_t mtime_secs = ap->mtime_days * 24 * 60 * 60;
@ -166,7 +166,7 @@ SFUNC(mtime)
}
#endif
#if ENABLE_FEATURE_FIND_MMIN
SFUNC(mmin)
ACTF(mmin)
{
time_t file_age = time(NULL) - statbuf->st_mtime;
time_t mmin_secs = ap->mmin_mins * 60;
@ -177,19 +177,19 @@ SFUNC(mmin)
}
#endif
#if ENABLE_FEATURE_FIND_NEWER
SFUNC(newer)
ACTF(newer)
{
return (ap->newer_mtime >= statbuf->st_mtime);
}
#endif
#if ENABLE_FEATURE_FIND_INUM
SFUNC(inum)
ACTF(inum)
{
return (statbuf->st_ino != ap->inode_num);
}
#endif
#if ENABLE_FEATURE_FIND_EXEC
SFUNC(exec)
ACTF(exec)
{
int i, rc;
char *argv[ap->exec_argc+1];
@ -207,21 +207,21 @@ SFUNC(exec)
#endif
#if ENABLE_FEATURE_FIND_PRINT0
SFUNC(print0)
ACTF(print0)
{
printf("%s%c", fileName, '\0');
return TRUE;
}
#endif
SFUNC(print)
ACTF(print)
{
puts(fileName);
return TRUE;
}
#if ENABLE_DESKTOP
SFUNC(paren)
ACTF(paren)
{
return exec_actions(ap->subexpr, fileName, statbuf);
}
@ -231,7 +231,7 @@ SFUNC(paren)
* Example:
* find dir -name 'asm-*' -prune -o -name '*.[chS]' -print
*/
SFUNC(prune)
ACTF(prune)
{
return SKIP;
}
@ -501,6 +501,7 @@ action*** parse_params(char **argv)
int find_main(int argc, char **argv)
{
int dereference = FALSE;
char *arg;
char **argp;
int i, firstopt, status = EXIT_SUCCESS;
@ -524,10 +525,9 @@ int find_main(int argc, char **argv)
// We implement: -follow, -xdev
/* Process options, and replace then with -a */
/* (that will be ignored by recursive parser later) */
/* (-a will be ignored by recursive parser later) */
argp = &argv[firstopt];
while (*argp) {
char *arg = argp[0];
while ((arg = argp[0])) {
if (strcmp(arg, "-follow") == 0) {
dereference = TRUE;
argp[0] = "-a";

View File

@ -72,8 +72,7 @@ int ps_main(int argc, char **argv)
safe_strncpy(sbuf, "unknown", 7);
}
len = printf("%5u %-32s %s ", (unsigned)p->pid, sbuf, p->state);
}
else
} else
#endif
if (p->rss == 0)
len = printf("%5u %-8s %s ", (unsigned)p->pid, p->user, p->state);

View File

@ -10,14 +10,7 @@
#include <sys/ioctl.h>
#include <sys/utsname.h>
#include <ctype.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
#include "busybox.h"
/* Copied from linux/rtc.h to eliminate the kernel dependency */
@ -42,17 +35,25 @@ struct linux_rtc_time {
# endif
#endif
static time_t read_rtc(int utc)
static int xopen_rtc(int flags)
{
int rtc;
rtc = open("/dev/rtc", flags);
if (rtc < 0) {
rtc = open("/dev/misc/rtc", flags);
if (rtc < 0)
bb_perror_msg_and_die("cannot access RTC");
}
return rtc;
}
static time_t read_rtc(int utc)
{
struct tm tm;
char *oldtz = 0;
time_t t = 0;
int rtc = xopen_rtc(O_RDONLY);
if (( rtc = open ( "/dev/rtc", O_RDONLY )) < 0 ) {
if (( rtc = open ( "/dev/misc/rtc", O_RDONLY )) < 0 )
bb_perror_msg_and_die ( "cannot access RTC" );
}
memset(&tm, 0, sizeof(struct tm));
if (ioctl(rtc, RTC_RD_TIME, &tm) < 0 )
bb_perror_msg_and_die("cannot read time from RTC");
@ -80,13 +81,8 @@ static time_t read_rtc(int utc)
static void write_rtc(time_t t, int utc)
{
int rtc;
struct tm tm;
if (( rtc = open ( "/dev/rtc", O_WRONLY )) < 0 ) {
if (( rtc = open ( "/dev/misc/rtc", O_WRONLY )) < 0 )
bb_perror_msg_and_die ( "cannot access RTC" );
}
int rtc = xopen_rtc(O_WRONLY);
tm = *(utc ? gmtime(&t) : localtime(&t));
tm.tm_isdst = 0;
@ -196,7 +192,6 @@ static const struct option hwclock_long_options[] = {
};
applet_long_options = hwclock_long_options;
#endif
opt_complementary = "?:r--ws:w--rs:s--wr:l--u:u--l";
opt = getopt32(argc, argv, "lursw");

View File

@ -52,10 +52,11 @@ int readprofile_main(int argc, char **argv)
unsigned int *buf, total, fn_len;
unsigned long long fn_add, next_add; /* current and next address */
char fn_name[S_LEN], next_name[S_LEN]; /* current and next name */
char mode[8];
int optAll=0, optInfo=0, optReset=0, optVerbose=0, optNative=0;
int optBins=0, optSub=0;
char mapline[S_LEN];
char mode[8];
int optAll = 0, optInfo = 0, optReset = 0;
int optVerbose = 0, optNative = 0;
int optBins = 0, optSub = 0;
int maplineno = 1;
int header_printed;
@ -87,7 +88,7 @@ int readprofile_main(int argc, char **argv)
fd = xopen(defaultpro, O_WRONLY);
if (write(fd, &multiplier, to_write) != to_write)
if (full_write(fd, &multiplier, to_write) != to_write)
bb_perror_msg_and_die("error writing %s", defaultpro);
close(fd);