mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-19 04:12:46 +00:00
Add R_UNUSED_RESULT and use it to avoid unnecessary -Wunused-result warnings
This commit is contained in:
parent
a9fb40057b
commit
ae108d7a69
@ -415,7 +415,9 @@ static RThread *sigchld_thread;
|
||||
|
||||
static void handle_sigchld(int sig) {
|
||||
ut8 b = 1;
|
||||
(void)write (sigchld_pipe[1], &b, 1);
|
||||
if (write (sigchld_pipe[1], &b, 1) != 1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static RThreadFunctionRet sigchld_th(RThread *th) {
|
||||
@ -502,7 +504,9 @@ R_API bool r2r_subprocess_init(void) {
|
||||
R_API void r2r_subprocess_fini(void) {
|
||||
r_sys_signal (SIGCHLD, SIG_IGN);
|
||||
ut8 b = 0;
|
||||
(void)write (sigchld_pipe[1], &b, 1);
|
||||
if (write (sigchld_pipe[1], &b, 1) != 1) {
|
||||
// nothing relevant here
|
||||
}
|
||||
close (sigchld_pipe [1]);
|
||||
r_th_wait (sigchld_thread);
|
||||
close (sigchld_pipe [0]);
|
||||
@ -743,7 +747,9 @@ R_API void r2r_subprocess_kill(R2RSubprocess *proc) {
|
||||
}
|
||||
|
||||
R_API void r2r_subprocess_stdin_write(R2RSubprocess *proc, const ut8 *buf, size_t buf_size) {
|
||||
(void)write (proc->stdin_fd, buf, buf_size);
|
||||
if (write (proc->stdin_fd, buf, buf_size) != buf_size) {
|
||||
// another ignored result
|
||||
}
|
||||
close (proc->stdin_fd);
|
||||
proc->stdin_fd = -1;
|
||||
}
|
||||
|
@ -886,7 +886,7 @@ static bool mnem_jbc(char const*const*arg, ut16 pc, ut8**out) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ut16 jmp_addr;
|
||||
ut16 jmp_addr = 0;
|
||||
if (!to_address (arg[1], &jmp_addr)) {
|
||||
R_LOG_DEBUG ("address %x not found", jmp_addr);
|
||||
return false;
|
||||
|
@ -154,6 +154,8 @@
|
||||
# define UNUSED_FUNCTION(x) UNUSED_ ## x
|
||||
#endif
|
||||
|
||||
#define R_UNUSED_RESULT(x) if ((x)) {}
|
||||
|
||||
#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
|
||||
#define __KFBSD__ 1
|
||||
#else
|
||||
|
@ -343,13 +343,17 @@ static void r2pm_setenv(void) {
|
||||
r_sys_setenv ("R2PM_PREFIX", r2_prefix);
|
||||
|
||||
char *pkgcfg = r_sys_getenv ("PKG_CONFIG_PATH");
|
||||
char *r2pm_pkgcfg = r_xdg_datadir ("prefix/lib/pkgconfig");
|
||||
if (R_STR_ISNOTEMPTY (pkgcfg)) {
|
||||
char *pcp = r_str_newf ("%s:%s", R2_PREFIX "/lib/pkgconfig", pkgcfg);
|
||||
char *pcp = r_str_newf ("%s:%s:%s", R2_PREFIX "/lib/pkgconfig", r2pm_pkgcfg, pkgcfg);
|
||||
r_sys_setenv ("PKG_CONFIG_PATH", pcp);
|
||||
free (pcp);
|
||||
} else {
|
||||
r_sys_setenv ("PKG_CONFIG_PATH", R2_PREFIX "/lib/pkgconfig");
|
||||
char *pcp = r_str_newf ("%s:%s", r2pm_pkgcfg, R2_PREFIX "/lib/pkgconfig");
|
||||
r_sys_setenv ("PKG_CONFIG_PATH", pcp);
|
||||
free (pcp);
|
||||
}
|
||||
free (r2pm_pkgcfg);
|
||||
free (pkgcfg);
|
||||
|
||||
char *bindir = r_str_newf ("%s/bin", r2_prefix);
|
||||
|
@ -1110,9 +1110,9 @@ R_API int r_main_radare2(int argc, const char **argv) {
|
||||
r_cons_set_raw (false);
|
||||
#if __UNIX__
|
||||
// TODO: keep flags :?
|
||||
(void)freopen ("/dev/tty", "rb", stdin);
|
||||
(void)freopen ("/dev/tty", "w", stdout);
|
||||
(void)freopen ("/dev/tty", "w", stderr);
|
||||
R_UNUSED_RESULT (freopen ("/dev/tty", "rb", stdin));
|
||||
R_UNUSED_RESULT (freopen ("/dev/tty", "w", stdout));
|
||||
R_UNUSED_RESULT (freopen ("/dev/tty", "w", stderr));
|
||||
#else
|
||||
R_LOG_ERROR ("Cannot reopen stdin without UNIX");
|
||||
free (buf);
|
||||
|
@ -390,15 +390,15 @@ static int bcb(RDiff *d, void *user, RDiffOp *op) {
|
||||
// we append data
|
||||
if (op->b_len <= 246) {
|
||||
ut8 data = op->b_len;
|
||||
(void) write (1, &data, 1);
|
||||
R_UNUSED_RESULT (write (1, &data, 1));
|
||||
} else if (op->b_len <= USHRT_MAX) {
|
||||
USLen = (ut16) op->b_len;
|
||||
ut8 data = 247;
|
||||
(void) write (1, &data, 1);
|
||||
R_UNUSED_RESULT (write (1, &data, 1));
|
||||
print_bytes (&USLen, sizeof (USLen), true);
|
||||
} else if (op->b_len <= INT_MAX) {
|
||||
ut8 data = 248;
|
||||
(void) write (1, &data, 1);
|
||||
R_UNUSED_RESULT (write (1, &data, 1));
|
||||
ILen = (int) op->b_len;
|
||||
print_bytes (&ILen, sizeof (ILen), true);
|
||||
} else {
|
||||
@ -1307,7 +1307,7 @@ R_API int r_main_radiff2(int argc, const char **argv) {
|
||||
pj_ka (ro.pj, "changes");
|
||||
}
|
||||
if (ro.diffmode == 'B') {
|
||||
(void) write (1, "\xd1\xff\xd1\xff\x04", 5);
|
||||
R_UNUSED_RESULT (write (1, "\xd1\xff\xd1\xff\x04", 5));
|
||||
}
|
||||
if (ro.diffmode == 'U') {
|
||||
char *res = r_diff_buffers_unified (d, bufa, (int)sza, bufb, (int)szb);
|
||||
@ -1318,7 +1318,7 @@ R_API int r_main_radiff2(int argc, const char **argv) {
|
||||
} else if (ro.diffmode == 'B') {
|
||||
r_diff_set_callback (d, &bcb, &ro);
|
||||
r_diff_buffers (d, bufa, (ut32)sza, bufb, (ut32)szb);
|
||||
(void) write (1, "\x00", 1);
|
||||
R_UNUSED_RESULT (write (1, "\x00", 1));
|
||||
} else {
|
||||
r_diff_set_callback (d, &cb, &ro);
|
||||
r_diff_buffers (d, bufa, (ut32)sza, bufb, (ut32)szb);
|
||||
|
Loading…
x
Reference in New Issue
Block a user