[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] size reduction and code clean up for devfsd.c
From: Bernhard Fischer <rep.dot.nop () gmail ! com>
Date: 2007-06-27 10:08:14
Message-ID: 20070627100814.GC5349 () aon ! at
[Download RAW message or body]
On Wed, Jun 27, 2007 at 09:44:39AM +0200, Tito wrote:
> On Wednesday 27 June 2007 02:20:00 Denis Vlasenko wrote:
> > > BTW: I'm seeing a lot of error messages now when compiling busybox:
> > >
> > > miscutils/devfsd.c: In function ???devfsd_main???:
> > > miscutils/devfsd.c:457: warning: ignoring return value of ???symlink???, \
> > > declared with attribute warn_unused_result
> > > miscutils/devfsd.c: In function ???copy_inode???:
> > > miscutils/devfsd.c:1062: warning: ignoring return value of ???symlink???, \
> > > declared with attribute warn_unused_result miscutils/devfsd.c:1067: warning: \
> > > ignoring return value of ???chown???, declared with attribute \
> > > warn_unused_result
> > > and so on....
> >
> > Should be coming from your libc.
> Hi,
> the strange thing is that this started when I began to use a fresh copy of busybox \
> svn. My old working copy never complained about this errors neither do all other \
> projects that I test compiled after seeing this. I haven't done system upgrades \
> involving libc, libc-dev or gcc. I'm using Ubuntu 7.04 (sort of).
These come from -D_FORTIFY_SOURCE=2 (or however it is called) which i
added to make people aware of eventual problems. It's off for WERROR.
Some of the warnings should be fixed, some are ok. It's just ment as a
helper for an audit pass.
I have a patch which flags alot if not all functions in libbb.h to warn
if they return a result but the result is not used.
Is this something we would like to help a general cleanup-pass?
PS: said patch is attached, for reference.
["busybox-libbb-warn-unused-result.00.diff" (text/x-diff)]
Index: include/libbb.h
===================================================================
--- include/libbb.h (revision 18893)
+++ include/libbb.h (working copy)
@@ -198,10 +198,10 @@ struct sysinfo {
unsigned int mem_unit; /* Memory unit size in bytes */
char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
};
-int sysinfo(struct sysinfo* info);
+int sysinfo(struct sysinfo* info) ATTRIBUTE_UNUSED_RESULT;
-unsigned long long monotonic_us(void);
-unsigned monotonic_sec(void);
+unsigned long long monotonic_us(void) ATTRIBUTE_UNUSED_RESULT;
+unsigned monotonic_sec(void) ATTRIBUTE_UNUSED_RESULT;
extern void chomp(char *s);
extern void trim(char *s);
@@ -210,7 +210,7 @@ extern char *skip_non_whitespace(const c
//TODO: supply a pointer to char[11] buffer (avoid statics)?
extern const char *bb_mode_string(mode_t mode);
-extern int is_directory(const char *name, int followLinks, struct stat *statBuf);
+extern int is_directory(const char *name, int followLinks, struct stat \
*statBuf)ATTRIBUTE_UNUSED_RESULT; extern int remove_file(const char *path, int \
flags); extern int copy_file(const char *source, const char *dest, int flags);
enum {
@@ -222,13 +222,13 @@ enum {
extern int recursive_action(const char *fileName, unsigned flags,
int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData, int \
depth), int (*dirAction) (const char *fileName, struct stat* statbuf, void* \
userData, int depth),
- void* userData, const unsigned depth);
-extern int device_open(const char *device, int mode);
-extern int get_console_fd(void);
-extern char *find_block_device(const char *path);
+ void* userData, const unsigned depth) ATTRIBUTE_UNUSED_RESULT;
+extern int device_open(const char *device, int mode) ATTRIBUTE_UNUSED_RESULT;
+extern int get_console_fd(void) ATTRIBUTE_UNUSED_RESULT;
+extern char *find_block_device(const char *path) ATTRIBUTE_UNUSED_RESULT;
/* bb_copyfd_XX print read/write errors and return -1 if they occur */
-extern off_t bb_copyfd_eof(int fd1, int fd2);
-extern off_t bb_copyfd_size(int fd1, int fd2, off_t size);
+extern off_t bb_copyfd_eof(int fd1, int fd2) ATTRIBUTE_UNUSED_RESULT;
+extern off_t bb_copyfd_size(int fd1, int fd2, off_t size) ATTRIBUTE_UNUSED_RESULT;
extern void bb_copyfd_exact_size(int fd1, int fd2, off_t size);
/* "short" copy can be detected by return value < size */
/* this helper yells "short read!" if param is not -1 */
@@ -238,17 +238,17 @@ extern char bb_process_escape_sequence(c
* makes it rather inconvenient at times: */
extern char *bb_get_last_path_component(char *path);
-int ndelay_on(int fd);
-int ndelay_off(int fd);
+int ndelay_on(int fd) ATTRIBUTE_UNUSED_RESULT;
+int ndelay_off(int fd) ATTRIBUTE_UNUSED_RESULT;
void xmove_fd(int, int);
-DIR *xopendir(const char *path);
-DIR *warn_opendir(const char *path);
+DIR *xopendir(const char *path) ATTRIBUTE_UNUSED_RESULT;
+DIR *warn_opendir(const char *path) ATTRIBUTE_UNUSED_RESULT;
-char *xrealloc_getcwd_or_warn(char *cwd);
-char *xmalloc_readlink_or_warn(const char *path);
-char *xmalloc_realpath(const char *path);
+char *xrealloc_getcwd_or_warn(char *cwd) ATTRIBUTE_UNUSED_RESULT;
+char *xmalloc_readlink_or_warn(const char *path) ATTRIBUTE_UNUSED_RESULT;
+char *xmalloc_realpath(const char *path) ATTRIBUTE_UNUSED_RESULT;
//TODO: signal(sid, f) is the same? then why?
@@ -267,24 +267,24 @@ void xchdir(const char *path);
void xsetenv(const char *key, const char *value);
void xunlink(const char *pathname);
void xstat(const char *pathname, struct stat *buf);
-int xopen(const char *pathname, int flags);
-int xopen3(const char *pathname, int flags, int mode);
-int open_or_warn(const char *pathname, int flags);
-int open3_or_warn(const char *pathname, int flags, int mode);
+int xopen(const char *pathname, int flags) ATTRIBUTE_UNUSED_RESULT;
+int xopen3(const char *pathname, int flags, int mode) ATTRIBUTE_UNUSED_RESULT;
+int open_or_warn(const char *pathname, int flags) ATTRIBUTE_UNUSED_RESULT;
+int open3_or_warn(const char *pathname, int flags, int mode) \
ATTRIBUTE_UNUSED_RESULT; void xpipe(int filedes[2]);
-off_t xlseek(int fd, off_t offset, int whence);
-off_t fdlength(int fd);
+off_t xlseek(int fd, off_t offset, int whence) ATTRIBUTE_UNUSED_RESULT;
+off_t fdlength(int fd) ATTRIBUTE_UNUSED_RESULT;
-int xsocket(int domain, int type, int protocol);
+int xsocket(int domain, int type, int protocol) ATTRIBUTE_UNUSED_RESULT;
void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
void xlisten(int s, int backlog);
void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen);
ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to,
socklen_t tolen);
-int setsockopt_reuseaddr(int fd);
-int setsockopt_broadcast(int fd);
+int setsockopt_reuseaddr(int fd) ATTRIBUTE_UNUSED_RESULT;
+int setsockopt_broadcast(int fd) ATTRIBUTE_UNUSED_RESULT;
/* NB: returns port in host byte order */
-unsigned bb_lookup_port(const char *port, const char *protocol, unsigned \
default_port); +unsigned bb_lookup_port(const char *port, const char *protocol, \
unsigned default_port) ATTRIBUTE_UNUSED_RESULT; typedef struct len_and_sockaddr {
socklen_t len;
union {
@@ -311,34 +311,34 @@ enum {
* af == AF_UNSPEC will result in trying to create IPv6, and
* if kernel doesn't support it, IPv4.
*/
-int xsocket_type(len_and_sockaddr **lsap, USE_FEATURE_IPV6(int af,) int sock_type);
-int xsocket_stream(len_and_sockaddr **lsap);
+int xsocket_type(len_and_sockaddr **lsap, USE_FEATURE_IPV6(int af,) int sock_type) \
ATTRIBUTE_UNUSED_RESULT; +int xsocket_stream(len_and_sockaddr **lsap) \
ATTRIBUTE_UNUSED_RESULT; /* Create server socket bound to bindaddr:port. bindaddr \
can be NULL,
* numeric IP ("N.N.N.N") or numeric IPv6 address,
* and can have ":PORT" suffix (for IPv6 use "[X:X:...:X]:PORT").
* Only if there is no suffix, port argument is used */
-int create_and_bind_stream_or_die(const char *bindaddr, int port);
-int create_and_bind_dgram_or_die(const char *bindaddr, int port);
+int create_and_bind_stream_or_die(const char *bindaddr, int port) \
ATTRIBUTE_UNUSED_RESULT; +int create_and_bind_dgram_or_die(const char *bindaddr, int \
port) ATTRIBUTE_UNUSED_RESULT; /* Create client TCP socket connected to peer:port. \
Peer cannot be NULL.
* Peer can be numeric IP ("N.N.N.N"), numeric IPv6 address or hostname,
* and can have ":PORT" suffix (for IPv6 use "[X:X:...:X]:PORT").
* If there is no suffix, port argument is used */
-int create_and_connect_stream_or_die(const char *peer, int port);
+int create_and_connect_stream_or_die(const char *peer, int port) \
ATTRIBUTE_UNUSED_RESULT; /* Connect to peer identified by lsa */
-int xconnect_stream(const len_and_sockaddr *lsa);
+int xconnect_stream(const len_and_sockaddr *lsa) ATTRIBUTE_UNUSED_RESULT;
/* Return malloc'ed len_and_sockaddr with socket address of host:port
* Currently will return IPv4 or IPv6 sockaddrs only
* (depending on host), but in theory nothing prevents e.g.
* UNIX socket address being returned, IPX sockaddr etc...
* On error does bb_error_msg and returns NULL */
-len_and_sockaddr* host2sockaddr(const char *host, int port);
+len_and_sockaddr* host2sockaddr(const char *host, int port) ATTRIBUTE_UNUSED_RESULT;
/* Version which dies on error */
-len_and_sockaddr* xhost2sockaddr(const char *host, int port);
-len_and_sockaddr* xdotted2sockaddr(const char *host, int port);
+len_and_sockaddr* xhost2sockaddr(const char *host, int port) \
ATTRIBUTE_UNUSED_RESULT; +len_and_sockaddr* xdotted2sockaddr(const char *host, int \
port) ATTRIBUTE_UNUSED_RESULT; #if ENABLE_FEATURE_IPV6
/* Same, useful if you want to force family (e.g. IPv6) */
-len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af);
-len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af);
+len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af) \
ATTRIBUTE_UNUSED_RESULT; +len_and_sockaddr* xhost_and_af2sockaddr(const char *host, \
int port, sa_family_t af) ATTRIBUTE_UNUSED_RESULT; #else
/* [we evaluate af: think about "host_and_af2sockaddr(..., af++)"] */
#define host_and_af2sockaddr(host, port, af) ((void)(af), host2sockaddr((host), \
(port))) @@ -349,19 +349,19 @@ len_and_sockaddr* xhost_and_af2sockaddr(
* NB: does NOT do htons() internally, just direct assignment. */
void set_nport(len_and_sockaddr *lsa, unsigned port);
/* Retrieve sin[6]_port or return -1 for non-INET[6] lsa's */
-int get_nport(const struct sockaddr *sa);
+int get_nport(const struct sockaddr *sa) ATTRIBUTE_UNUSED_RESULT;
/* Reverse DNS. Returns NULL on failure. */
-char* xmalloc_sockaddr2host(const struct sockaddr *sa, socklen_t salen);
+char* xmalloc_sockaddr2host(const struct sockaddr *sa, socklen_t salen) \
ATTRIBUTE_UNUSED_RESULT; /* This one doesn't append :PORTNUM */
-char* xmalloc_sockaddr2host_noport(const struct sockaddr *sa, socklen_t salen);
+char* xmalloc_sockaddr2host_noport(const struct sockaddr *sa, socklen_t salen) \
ATTRIBUTE_UNUSED_RESULT; /* This one also doesn't fall back to dotted IP (returns \
NULL) */
-char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa, socklen_t salen);
+char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa, socklen_t salen) \
ATTRIBUTE_UNUSED_RESULT; /* inet_[ap]ton on steroids */
-char* xmalloc_sockaddr2dotted(const struct sockaddr *sa, socklen_t salen);
-char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa, socklen_t salen);
+char* xmalloc_sockaddr2dotted(const struct sockaddr *sa, socklen_t salen) \
ATTRIBUTE_UNUSED_RESULT; +char* xmalloc_sockaddr2dotted_noport(const struct sockaddr \
*sa, socklen_t salen) ATTRIBUTE_UNUSED_RESULT; // "old" (ipv4 only) API
// users: traceroute.c hostname.c - use _list_ of all IPs
-struct hostent *xgethostbyname(const char *name);
+struct hostent *xgethostbyname(const char *name) ATTRIBUTE_UNUSED_RESULT;
// Also mount.c and inetd.c are using gethostbyname(),
// + inet_common.c has additional IPv4-only stuff
@@ -369,16 +369,16 @@ struct hostent *xgethostbyname(const cha
void socket_want_pktinfo(int fd);
ssize_t send_to_from(int fd, void *buf, size_t len, int flags,
const struct sockaddr *from, const struct sockaddr *to,
- socklen_t tolen);
+ socklen_t tolen) ATTRIBUTE_UNUSED_RESULT;
ssize_t recv_from_to(int fd, void *buf, size_t len, int flags,
struct sockaddr *from, struct sockaddr *to,
- socklen_t sa_size);
+ socklen_t sa_size) ATTRIBUTE_UNUSED_RESULT;
-extern char *xstrdup(const char *s);
-extern char *xstrndup(const char *s, int n);
-extern char *safe_strncpy(char *dst, const char *src, size_t size);
-extern char *xasprintf(const char *format, ...) __attribute__ ((format (printf, 1, \
2))); +extern char *xstrdup(const char *s) ATTRIBUTE_UNUSED_RESULT;
+extern char *xstrndup(const char *s, int n) ATTRIBUTE_UNUSED_RESULT;
+extern char *safe_strncpy(char *dst, const char *src, size_t size) \
ATTRIBUTE_UNUSED_RESULT; +extern char *xasprintf(const char *format, ...) \
__attribute__ ((format (printf, 1, 2))) ATTRIBUTE_UNUSED_RESULT; // gcc-4.1.1 still \
isn't good enough at optimizing it // (+200 bytes compared to macro)
//static ALWAYS_INLINE
@@ -393,59 +393,59 @@ extern char *xasprintf(const char *forma
/* dmalloc will redefine these to it's own implementation. It is safe
* to have the prototypes here unconditionally. */
-extern void *malloc_or_warn(size_t size);
-extern void *xmalloc(size_t size);
-extern void *xzalloc(size_t size);
-extern void *xrealloc(void *old, size_t size);
+extern void *malloc_or_warn(size_t size) ATTRIBUTE_UNUSED_RESULT;
+extern void *xmalloc(size_t size) ATTRIBUTE_UNUSED_RESULT;
+extern void *xzalloc(size_t size) ATTRIBUTE_UNUSED_RESULT;
+extern void *xrealloc(void *old, size_t size) ATTRIBUTE_UNUSED_RESULT;
-extern ssize_t safe_read(int fd, void *buf, size_t count);
-extern ssize_t full_read(int fd, void *buf, size_t count);
+extern ssize_t safe_read(int fd, void *buf, size_t count) ATTRIBUTE_UNUSED_RESULT;
+extern ssize_t full_read(int fd, void *buf, size_t count) ATTRIBUTE_UNUSED_RESULT;
extern void xread(int fd, void *buf, size_t count);
-extern unsigned char xread_char(int fd);
+extern unsigned char xread_char(int fd) ATTRIBUTE_UNUSED_RESULT;
// Read one line a-la fgets. Uses one read(), works only on seekable streams
-extern char *reads(int fd, char *buf, size_t count);
+extern char *reads(int fd, char *buf, size_t count) ATTRIBUTE_UNUSED_RESULT;
// Read one line a-la fgets. Reads byte-by-byte.
// Useful when it is important to not read ahead.
-extern char *xmalloc_reads(int fd, char *pfx);
-extern ssize_t read_close(int fd, void *buf, size_t count);
-extern ssize_t open_read_close(const char *filename, void *buf, size_t count);
-extern void *xmalloc_open_read_close(const char *filename, size_t *sizep);
+extern char *xmalloc_reads(int fd, char *pfx) ATTRIBUTE_UNUSED_RESULT;
+extern ssize_t read_close(int fd, void *buf, size_t count) ATTRIBUTE_UNUSED_RESULT;
+extern ssize_t open_read_close(const char *filename, void *buf, size_t count) \
ATTRIBUTE_UNUSED_RESULT; +extern void *xmalloc_open_read_close(const char *filename, \
size_t *sizep) ATTRIBUTE_UNUSED_RESULT;
-extern ssize_t safe_write(int fd, const void *buf, size_t count);
-extern ssize_t full_write(int fd, const void *buf, size_t count);
+extern ssize_t safe_write(int fd, const void *buf, size_t count) \
ATTRIBUTE_UNUSED_RESULT; +extern ssize_t full_write(int fd, const void *buf, size_t \
count) ATTRIBUTE_UNUSED_RESULT; extern void xwrite(int fd, const void *buf, size_t \
count);
/* Reads and prints to stdout till eof, then closes FILE. Exits on error: */
extern void xprint_and_close_file(FILE *file);
-extern char *xmalloc_fgets(FILE *file);
+extern char *xmalloc_fgets(FILE *file) ATTRIBUTE_UNUSED_RESULT;
/* Read up to (and including) TERMINATING_STRING: */
-extern char *xmalloc_fgets_str(FILE *file, const char *terminating_string);
+extern char *xmalloc_fgets_str(FILE *file, const char *terminating_string) \
ATTRIBUTE_UNUSED_RESULT; /* Chops off '\n' from the end, unlike fgets: */
-extern char *xmalloc_getline(FILE *file);
-extern char *bb_get_chunk_from_file(FILE *file, int *end);
+extern char *xmalloc_getline(FILE *file) ATTRIBUTE_UNUSED_RESULT;
+extern char *bb_get_chunk_from_file(FILE *file, int *end) ATTRIBUTE_UNUSED_RESULT;
extern void die_if_ferror(FILE *file, const char *msg);
extern void die_if_ferror_stdout(void);
extern void xfflush_stdout(void);
extern void fflush_stdout_and_exit(int retval) ATTRIBUTE_NORETURN;
extern int fclose_if_not_stdin(FILE *file);
-extern FILE *xfopen(const char *filename, const char *mode);
+extern FILE *xfopen(const char *filename, const char *mode) ATTRIBUTE_UNUSED_RESULT;
/* Prints warning to stderr and returns NULL on failure: */
-extern FILE *fopen_or_warn(const char *filename, const char *mode);
+extern FILE *fopen_or_warn(const char *filename, const char *mode) \
ATTRIBUTE_UNUSED_RESULT; /* "Opens" stdin if filename is special, else just opens \
file: */
-extern FILE *fopen_or_warn_stdin(const char *filename);
+extern FILE *fopen_or_warn_stdin(const char *filename) ATTRIBUTE_UNUSED_RESULT;
/* Convert each alpha char in str to lower-case */
-extern char* str_tolower(char *str);
+extern char* str_tolower(char *str) ATTRIBUTE_UNUSED_RESULT;
-char *utoa(unsigned n);
-char *itoa(int n);
+char *utoa(unsigned n) ATTRIBUTE_UNUSED_RESULT;
+char *itoa(int n) ATTRIBUTE_UNUSED_RESULT;
/* Returns a pointer past the formatted number, does NOT null-terminate */
char *utoa_to_buf(unsigned n, char *buf, unsigned buflen);
char *itoa_to_buf(int n, char *buf, unsigned buflen);
void smart_ulltoa5(unsigned long long ul, char buf[5]);
//TODO: provide pointer to buf (avoid statics)?
const char *make_human_readable_str(unsigned long long size,
- unsigned long block_size, unsigned long display_unit);
+ unsigned long block_size, unsigned long display_unit) ATTRIBUTE_UNUSED_RESULT;
/* Put a string of hex bytes ("1b2e66fe"...), return advanced pointer */
char *bin2hex(char *buf, const char *cp, int count);
@@ -459,43 +459,43 @@ struct suffix_mult {
* in many places people want *non-negative* values, but store them
* in signed int. Therefore we need this one:
* dies if input is not in [0, INT_MAX] range. Also will reject '-0' etc */
-int xatoi_u(const char *numstr);
+int xatoi_u(const char *numstr) ATTRIBUTE_UNUSED_RESULT;
/* Useful for reading port numbers */
-uint16_t xatou16(const char *numstr);
+uint16_t xatou16(const char *numstr) ATTRIBUTE_UNUSED_RESULT;
/* These parse entries in /etc/passwd and /etc/group. This is desirable
* for BusyBox since we want to avoid using the glibc NSS stuff, which
* increases target size and is often not needed on embedded systems. */
-long xuname2uid(const char *name);
-long xgroup2gid(const char *name);
+long xuname2uid(const char *name) ATTRIBUTE_UNUSED_RESULT;
+long xgroup2gid(const char *name) ATTRIBUTE_UNUSED_RESULT;
/* wrapper: allows string to contain numeric uid or gid */
-unsigned long get_ug_id(const char *s, long (*xname2id)(const char *));
+unsigned long get_ug_id(const char *s, long (*xname2id)(const char *)) \
ATTRIBUTE_UNUSED_RESULT; /* from chpst. Does not die, returns 0 on failure */
struct bb_uidgid_t {
uid_t uid;
gid_t gid;
};
/* always sets uid and gid */
-int get_uidgid(struct bb_uidgid_t*, const char*, int numeric_ok);
+int get_uidgid(struct bb_uidgid_t*, const char*, int numeric_ok) \
ATTRIBUTE_UNUSED_RESULT; /* chown-like handling of "user[:[group]" */
void parse_chown_usergroup_or_die(struct bb_uidgid_t *u, char *user_group);
/* what is this? */
/*extern char *bb_getug(char *buffer, char *idname, long id, int bufsize, char \
prefix);*/
-char *bb_getpwuid(char *name, long uid, int bufsize);
-char *bb_getgrgid(char *group, long gid, int bufsize);
+char *bb_getpwuid(char *name, long uid, int bufsize) ATTRIBUTE_UNUSED_RESULT;
+char *bb_getgrgid(char *group, long gid, int bufsize) ATTRIBUTE_UNUSED_RESULT;
/* versions which cache results (useful for ps, ls etc) */
-const char* get_cached_username(uid_t uid);
-const char* get_cached_groupname(gid_t gid);
+const char* get_cached_username(uid_t uid) ATTRIBUTE_UNUSED_RESULT;
+const char* get_cached_groupname(gid_t gid) ATTRIBUTE_UNUSED_RESULT;
void clear_username_cache(void);
/* internally usernames are saved in fixed-sized char[] buffers */
enum { USERNAME_MAX_SIZE = 16 - sizeof(int) };
struct bb_applet;
-int execable_file(const char *name);
-char *find_execable(const char *filename);
-int exists_execable(const char *filename);
+int execable_file(const char *name) ATTRIBUTE_UNUSED_RESULT;
+char *find_execable(const char *filename) ATTRIBUTE_UNUSED_RESULT;
+int exists_execable(const char *filename) ATTRIBUTE_UNUSED_RESULT;
#if ENABLE_FEATURE_PREFER_APPLETS
int bb_execvp(const char *file, char *const argv[]);
@@ -509,8 +509,8 @@ int bb_execvp(const char *file, char *co
#endif
/* NOMMU friendy fork+exec */
-pid_t spawn(char **argv);
-pid_t xspawn(char **argv);
+pid_t spawn(char **argv) ATTRIBUTE_UNUSED_RESULT;
+pid_t xspawn(char **argv) ATTRIBUTE_UNUSED_RESULT;
/* Unlike waitpid, waits ONLY for one process,
* It's safe to pass negative 'pids' from failed [v]fork -
@@ -519,15 +519,15 @@ pid_t xspawn(char **argv);
* if (rc < 0) bb_perror_msg("%s", argv[0]);
* if (rc > 0) bb_error_msg("exit code: %d", rc);
*/
-int wait4pid(int pid);
-int wait_pid(int *wstat, int pid);
-int wait_nohang(int *wstat);
+int wait4pid(int pid) ATTRIBUTE_UNUSED_RESULT;
+int wait_pid(int *wstat, int pid) ATTRIBUTE_UNUSED_RESULT;
+int wait_nohang(int *wstat) ATTRIBUTE_UNUSED_RESULT;
#define wait_crashed(w) ((w) & 127)
#define wait_exitcode(w) ((w) >> 8)
#define wait_stopsig(w) ((w) >> 8)
#define wait_stopped(w) (((w) & 127) == 127)
/* wait4pid(spawn(argv)) + NOFORK/NOEXEC (if configured) */
-int spawn_and_wait(char **argv);
+int spawn_and_wait(char **argv) ATTRIBUTE_UNUSED_RESULT;
struct nofork_save_area {
jmp_buf die_jmp;
const struct bb_applet *current_applet;
@@ -539,8 +539,8 @@ struct nofork_save_area {
void save_nofork_data(struct nofork_save_area *save);
void restore_nofork_data(struct nofork_save_area *save);
/* Does NOT check that applet is NOFORK, just blindly runs it */
-int run_nofork_applet(const struct bb_applet *a, char **argv);
-int run_nofork_applet_prime(struct nofork_save_area *old, const struct bb_applet *a, \
char **argv); +int run_nofork_applet(const struct bb_applet *a, char **argv) \
ATTRIBUTE_UNUSED_RESULT; +int run_nofork_applet_prime(struct nofork_save_area *old, \
const struct bb_applet *a, char **argv) ATTRIBUTE_UNUSED_RESULT;
/* Helpers for daemonization.
*
@@ -606,14 +606,14 @@ void llist_add_to_end(llist_t **list_hea
void *llist_pop(llist_t **elm);
void llist_unlink(llist_t **head, llist_t *elm);
void llist_free(llist_t *elm, void (*freeit)(void *data));
-llist_t *llist_rev(llist_t *list);
+llist_t *llist_rev(llist_t *list) ATTRIBUTE_UNUSED_RESULT;
/* BTW, surprisingly, changing API to
* llist_t *llist_add_to(llist_t *old_head, void *data)
* etc does not result in smaller code... */
#if ENABLE_FEATURE_PIDFILE
-int write_pidfile(const char *path);
+int write_pidfile(const char *path) ATTRIBUTE_UNUSED_RESULT;
#define remove_pidfile(f) ((void)unlink(f))
#else
/* Why? #defining it to 1 gives "warning: statement with no effect"... */
@@ -669,8 +669,8 @@ int bbunpack(char **argv,
/* Networking */
-int create_icmp_socket(void);
-int create_icmp6_socket(void);
+int create_icmp_socket(void) ATTRIBUTE_UNUSED_RESULT;
+int create_icmp6_socket(void) ATTRIBUTE_UNUSED_RESULT;
/* interface.c */
/* This structure defines protocol families and their handlers. */
struct aftype {
@@ -700,56 +700,56 @@ struct hwtype {
int suppress_null_addr;
};
extern smallint interface_opt_a;
-int display_interfaces(char *ifname);
-const struct aftype *get_aftype(const char *name);
-const struct hwtype *get_hwtype(const char *name);
-const struct hwtype *get_hwntype(int type);
+int display_interfaces(char *ifname) ATTRIBUTE_UNUSED_RESULT;
+const struct aftype *get_aftype(const char *name) ATTRIBUTE_UNUSED_RESULT;
+const struct hwtype *get_hwtype(const char *name) ATTRIBUTE_UNUSED_RESULT;
+const struct hwtype *get_hwntype(int type) ATTRIBUTE_UNUSED_RESULT;
#ifndef BUILD_INDIVIDUAL
-extern const struct bb_applet *find_applet_by_name(const char *name);
+extern const struct bb_applet *find_applet_by_name(const char *name) \
ATTRIBUTE_UNUSED_RESULT; /* Returns only if applet is not found. */
extern void run_applet_and_exit(const char *name, char **argv);
extern void run_current_applet_and_exit(char **argv) ATTRIBUTE_NORETURN;
#endif
-extern int match_fstype(const struct mntent *mt, const char *fstypes);
-extern struct mntent *find_mount_point(const char *name, const char *table);
+extern int match_fstype(const struct mntent *mt, const char *fstypes) \
ATTRIBUTE_UNUSED_RESULT; +extern struct mntent *find_mount_point(const char *name, \
const char *table) ATTRIBUTE_UNUSED_RESULT; extern void erase_mtab(const char * \
name);
-extern unsigned int tty_baud_to_value(speed_t speed);
-extern speed_t tty_value_to_baud(unsigned int value);
+extern unsigned int tty_baud_to_value(speed_t speed) ATTRIBUTE_UNUSED_RESULT;
+extern speed_t tty_value_to_baud(unsigned int value) ATTRIBUTE_UNUSED_RESULT;
extern void bb_warn_ignoring_args(int n);
-extern int get_linux_version_code(void);
+extern int get_linux_version_code(void) ATTRIBUTE_UNUSED_RESULT;
-extern char *query_loop(const char *device);
+extern char *query_loop(const char *device) ATTRIBUTE_UNUSED_RESULT;
extern int del_loop(const char *device);
extern int set_loop(char **device, const char *file, unsigned long long offset);
//TODO: pass buf pointer or return allocated buf (avoid statics)?
-char *bb_askpass(int timeout, const char * prompt);
-int bb_ask_confirmation(void);
+char *bb_askpass(int timeout, const char * prompt) ATTRIBUTE_UNUSED_RESULT;
+int bb_ask_confirmation(void) ATTRIBUTE_UNUSED_RESULT;
int klogctl(int type, char * b, int len);
extern int bb_parse_mode(const char* s, mode_t* theMode);
-char *concat_path_file(const char *path, const char *filename);
-char *concat_subpath_file(const char *path, const char *filename);
+char *concat_path_file(const char *path, const char *filename) \
ATTRIBUTE_UNUSED_RESULT; +char *concat_subpath_file(const char *path, const char \
*filename) ATTRIBUTE_UNUSED_RESULT; /* NB: can violate const-ness (similarly to \
strchr) */ char *last_char_is(const char *s, int c);
-USE_DESKTOP(long long) int uncompress(int fd_in, int fd_out);
-int inflate(int in, int out);
+USE_DESKTOP(long long) int uncompress(int fd_in, int fd_out) \
ATTRIBUTE_UNUSED_RESULT; +int inflate(int in, int out) ATTRIBUTE_UNUSED_RESULT;
int bb_make_directory(char *path, long mode, int flags);
-int get_signum(const char *name);
-const char *get_signame(int number);
+int get_signum(const char *name) ATTRIBUTE_UNUSED_RESULT;
+const char *get_signame(int number) ATTRIBUTE_UNUSED_RESULT;
-char *bb_simplify_path(const char *path);
+char *bb_simplify_path(const char *path) ATTRIBUTE_UNUSED_RESULT;
#define FAIL_DELAY 3
extern void bb_do_delay(int seconds);
@@ -764,13 +764,13 @@ extern context_t set_security_context_co
extern void setfscreatecon_or_die(security_context_t scontext);
#endif
extern void selinux_or_die(void);
-extern int restricted_shell(const char *shell);
+extern int restricted_shell(const char *shell) ATTRIBUTE_UNUSED_RESULT;
extern void setup_environment(const char *shell, int loginshell, int changeenv, \
const struct passwd *pw);
-extern int correct_password(const struct passwd *pw);
+extern int correct_password(const struct passwd *pw) ATTRIBUTE_UNUSED_RESULT;
extern char *pw_encrypt(const char *clear, const char *salt);
extern int obscure(const char *old, const char *newval, const struct passwd *pwdp);
-extern int index_in_str_array(const char * const string_array[], const char *key);
-extern int index_in_substr_array(const char * const string_array[], const char \
*key); +extern int index_in_str_array(const char * const string_array[], const char \
*key) ATTRIBUTE_UNUSED_RESULT; +extern int index_in_substr_array(const char * const \
string_array[], const char *key) ATTRIBUTE_UNUSED_RESULT; extern void \
print_login_issue(const char *issue_file, const char *tty); extern void \
print_login_prompt(void);
@@ -783,7 +783,7 @@ void add_to_ino_dev_hashtable(const stru
void reset_ino_dev_hashtable(void);
#ifdef __GLIBC__
/* At least glibc has horrendously large inline for this, so wrap it */
-unsigned long long bb_makedev(unsigned int major, unsigned int minor);
+unsigned long long bb_makedev(unsigned int major, unsigned int minor) \
ATTRIBUTE_UNUSED_RESULT; #undef makedev
#define makedev(a,b) bb_makedev(a,b)
#endif
@@ -815,10 +815,10 @@ enum {
WITH_PATH_LOOKUP = 0x20,
FOR_SHELL = DO_HISTORY | SAVE_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION,
};
-line_input_t *new_line_input_t(int flags);
-int read_line_input(const char* prompt, char* command, int maxsize, line_input_t \
*state); +line_input_t *new_line_input_t(int flags) ATTRIBUTE_UNUSED_RESULT;
+int read_line_input(const char* prompt, char* command, int maxsize, line_input_t \
*state) ATTRIBUTE_UNUSED_RESULT; #else
-int read_line_input(const char* prompt, char* command, int maxsize);
+int read_line_input(const char* prompt, char* command, int maxsize) \
ATTRIBUTE_UNUSED_RESULT; #define read_line_input(prompt, command, maxsize, state) \
read_line_input(prompt, command, maxsize)
#endif
_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic