mirror of
https://github.com/radareorg/radare2.git
synced 2024-10-07 02:23:58 +00:00
Update sdb and fix some more unused return value warnings
This commit is contained in:
parent
60182bb63a
commit
82794237d7
@ -36,7 +36,7 @@ radare2/sys/install.sh
|
||||
```
|
||||
|
||||
```sh
|
||||
pip install r2env
|
||||
pip install -U r2env
|
||||
r2env init
|
||||
r2env add radare2@git
|
||||
```
|
||||
|
@ -217,7 +217,10 @@ static bool print_reglist(RStrBuf *sb, v850np_inst *inst, const struct v850_oper
|
||||
|
||||
if (last > first + 1) {
|
||||
for (i = first + 1; i < last ; i++) {
|
||||
r_strbuf_appendf (sb, ", %s", get_v850_reg_name (i)); // last - 1));
|
||||
const char *rn = get_v850_reg_name (i);
|
||||
if (rn) {
|
||||
r_strbuf_appendf (sb, ", %s", rn);
|
||||
}
|
||||
}
|
||||
//r_strbuf_appendf (sb, " - %s", get_v850_reg_name (last - 1));
|
||||
}
|
||||
|
@ -1595,13 +1595,18 @@ static bool __xterm_get_size(void) {
|
||||
return false;
|
||||
}
|
||||
int rows, columns;
|
||||
(void)write (I->fdout, "\x1b[999;999H", sizeof ("\x1b[999;999H"));
|
||||
const char nainnain[] = "\x1b[999;999H";
|
||||
if (write (I->fdout, nainnain, sizeof (nainnain)) != sizeof (nainnain)) {
|
||||
return false;
|
||||
}
|
||||
rows = __xterm_get_cur_pos (&columns);
|
||||
if (rows) {
|
||||
I->rows = rows;
|
||||
I->columns = columns;
|
||||
} // otherwise reuse previous values
|
||||
(void)write (I->fdout, R_CONS_CURSOR_RESTORE, sizeof (R_CONS_CURSOR_RESTORE));
|
||||
if (write (I->fdout, R_CONS_CURSOR_RESTORE, sizeof (R_CONS_CURSOR_RESTORE) != sizeof (R_CONS_CURSOR_RESTORE)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1749,7 +1754,9 @@ R_API void r_cons_show_cursor(int cursor) {
|
||||
#if __WINDOWS__
|
||||
if (I->vtmode) {
|
||||
#endif
|
||||
(void) write (1, cursor ? "\x1b[?25h" : "\x1b[?25l", 6);
|
||||
if (write (1, cursor ? "\x1b[?25h" : "\x1b[?25l", 6) != 6) {
|
||||
C->breaked = true;
|
||||
}
|
||||
#if __WINDOWS__
|
||||
} else {
|
||||
static HANDLE hStdout = NULL;
|
||||
@ -1930,7 +1937,9 @@ R_API void r_cons_zero(void) {
|
||||
if (I->line) {
|
||||
I->line->zerosep = true;
|
||||
}
|
||||
(void)write (1, "", 1);
|
||||
if (write (1, "", 1) != 1) {
|
||||
C->breaked = true;
|
||||
}
|
||||
}
|
||||
|
||||
R_API void r_cons_highlight(const char *word) {
|
||||
@ -2240,7 +2249,9 @@ R_API void r_cons_cmd_help_match(const char *help[], bool use_color, R_BORROW R_
|
||||
|
||||
R_API void r_cons_clear_buffer(void) {
|
||||
if (I->vtmode) {
|
||||
(void)write (1, "\x1b" "c\x1b[3J", 6);
|
||||
if (write (1, "\x1b" "c\x1b[3J", 6) != 6) {
|
||||
C->breaked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,6 @@ R_API int r_cmd_alias_set_raw(RCmd *cmd, const char *k, const ut8 *v, int sz) {
|
||||
|
||||
R_API RCmdAliasVal *r_cmd_alias_get(RCmd *cmd, const char *k) {
|
||||
r_return_val_if_fail (cmd && cmd->aliases && k, NULL);
|
||||
|
||||
return ht_pp_find(cmd->aliases, k, NULL);
|
||||
}
|
||||
|
||||
@ -427,20 +426,16 @@ R_API int r_cmd_alias_append_str(RCmd *cmd, const char *k, const char *a) {
|
||||
if (!v_old->is_data) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int new_len;
|
||||
int new_len = 0;
|
||||
ut8* new = alias_append_internal (&new_len, v_old, (ut8 *)a, strlen (a) + 1);
|
||||
|
||||
if (!new) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
r_cmd_alias_set_raw (cmd, k, new, new_len);
|
||||
free (new);
|
||||
} else {
|
||||
r_cmd_alias_set_str (cmd, k, a);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -450,16 +445,16 @@ R_API int r_cmd_alias_append_raw(RCmd *cmd, const char *k, const ut8 *a, int sz)
|
||||
if (!v_old->is_data) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int new_len;
|
||||
int new_len = 0;
|
||||
ut8 *new = alias_append_internal (&new_len, v_old, a, sz);
|
||||
|
||||
if (!new) {
|
||||
return 1;
|
||||
}
|
||||
r_cmd_alias_set_raw (cmd, k, new, new_len);
|
||||
free (new);
|
||||
} else {
|
||||
r_cmd_alias_set_raw (cmd, k, a, sz);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -468,7 +463,6 @@ R_API char *r_cmd_alias_val_strdup(RCmdAliasVal *v) {
|
||||
if (v->is_str) {
|
||||
return strdup ((char *)v->data);
|
||||
}
|
||||
|
||||
return r_str_escape_raw (v->data, v->sz);
|
||||
}
|
||||
|
||||
|
@ -159,15 +159,18 @@ static bool lang_pipe_run(RLang *lang, const char *code, int len) {
|
||||
r_sys_perror ("pipe run");
|
||||
} else if (!child) {
|
||||
/* children */
|
||||
int rc = 0;
|
||||
r_sandbox_system (code, 1);
|
||||
write (input[1], "", 1);
|
||||
if (write (input[1], "", 1) != 1) {
|
||||
rc = 1;
|
||||
}
|
||||
close (input[0]);
|
||||
close (input[1]);
|
||||
close (output[0]);
|
||||
close (output[1]);
|
||||
fflush (stdout);
|
||||
fflush (stderr);
|
||||
r_sys_exit (0, true);
|
||||
r_sys_exit (rc, true);
|
||||
return false;
|
||||
} else {
|
||||
/* parent */
|
||||
@ -194,11 +197,16 @@ static bool lang_pipe_run(RLang *lang, const char *code, int len) {
|
||||
res = lang->cmd_str ((RCore*)lang->user, buf);
|
||||
if (res) {
|
||||
// r_cons_print (res);
|
||||
(void) write (input[1], res, strlen (res) + 1);
|
||||
size_t res_len = strlen (res) + 1;
|
||||
if (write (input[1], res, res_len) != res_len) {
|
||||
break;
|
||||
}
|
||||
free (res);
|
||||
} else {
|
||||
eprintf ("r_lang_pipe: NULL reply for (%s)\n", buf);
|
||||
(void) write (input[1], "", 1); // NULL byte
|
||||
if (write (input[1], "", 1) != 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
r_cons_break_pop ();
|
||||
|
@ -81,6 +81,7 @@ r_main_dep = declare_dependency(link_with: r_main,
|
||||
include_directories: [platform_inc],
|
||||
dependencies: r_main_deps)
|
||||
|
||||
if get_option('blob')
|
||||
r_main_static = static_library('r_main_static', r_main_sources,
|
||||
include_directories: [platform_inc],
|
||||
c_args: library_cflags,
|
||||
@ -94,6 +95,7 @@ r_main_static_dep = declare_dependency(
|
||||
include_directories: [platform_inc],
|
||||
dependencies: r_main_static_deps
|
||||
)
|
||||
endif
|
||||
|
||||
pkgconfig_mod.generate(r_main,
|
||||
subdirs: 'libr',
|
||||
|
@ -306,7 +306,9 @@ R_API R2Pipe *r2pipe_open(const char *cmd) {
|
||||
eprintf ("return code %d for %s\n", rc, cmd);
|
||||
}
|
||||
// trigger the blocking read
|
||||
write (1, "\xff", 1);
|
||||
if (write (1, "\xff", 1) != 1) {
|
||||
rc = -1;
|
||||
}
|
||||
close (r2p->output[1]);
|
||||
close (0);
|
||||
close (1);
|
||||
|
@ -69,9 +69,9 @@ ifeq (1,$(WITH_GPL))
|
||||
MODS+=grub
|
||||
endif
|
||||
endif
|
||||
SDB_URL=git://github.com/radareorg/sdb
|
||||
SDB_URL=https://github.com/radareorg/sdb
|
||||
#SDB_URL=/Users/pancake/prg/sdb
|
||||
SPP_URL=git://github.com/trufae/spp
|
||||
SPP_URL=https://github.com/trufae/spp
|
||||
PWD=$(shell pwd)
|
||||
SDB_CONFIG=${PWD}/sdb-config.mk
|
||||
|
||||
|
@ -6,7 +6,7 @@ INCDIR=${PREFIX}/include
|
||||
VAPIDIR=${DATADIR}/vala/vapi/
|
||||
MANDIR=${DATADIR}/man/man1
|
||||
|
||||
SDBVER=1.8.5
|
||||
SDBVER=1.8.6
|
||||
|
||||
BUILD_MEMCACHE=0
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
/* XXX: this code must be rewritten . too slow */
|
||||
bool cdb_getkvlen(struct cdb *c, ut32 *klen, ut32 *vlen, ut32 pos) {
|
||||
ut8 buf[4] = {0};
|
||||
ut8 buf[4] = { 0 };
|
||||
*klen = *vlen = 0;
|
||||
if (!cdb_read (c, (char *)buf, sizeof (buf), pos)) {
|
||||
return false;
|
||||
|
@ -59,8 +59,10 @@ static void terminate(int sig UNUSED) {
|
||||
exit (sig < 2? sig: 0);
|
||||
}
|
||||
|
||||
static void write_null(void) {
|
||||
(void)write (1, "", 1);
|
||||
static int write_null(void) {
|
||||
// success = write returns 1 == 1 -> 0
|
||||
// failure = write returns 0 != 1 -> 1
|
||||
return write (1, "", 1) != 1;
|
||||
}
|
||||
|
||||
#define BS 128
|
||||
@ -456,7 +458,7 @@ static int sdb_dump(MainOptions *mo) {
|
||||
const bool grep = mo->grep;
|
||||
|
||||
char *v = NULL;
|
||||
char k[SDB_MAX_KEY] = {0};
|
||||
char k[SDB_MAX_KEY] = { 0 };
|
||||
const char *comma = "";
|
||||
Sdb *db = sdb_new (NULL, dbname, 0);
|
||||
if (!db) {
|
||||
@ -478,6 +480,7 @@ static int sdb_dump(MainOptions *mo) {
|
||||
break;
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
if (db->fd == -1) {
|
||||
SdbList *l = sdb_foreach_list (db, true);
|
||||
if (!mo->textmode && mo->format == cgen && ls_length (l) > SDB_MAX_GPERF_KEYS) {
|
||||
@ -511,31 +514,31 @@ static int sdb_dump(MainOptions *mo) {
|
||||
free (v);
|
||||
if (!mo->textmode && mo->format == cgen && count++ > SDB_MAX_GPERF_KEYS) {
|
||||
eprintf ("Error: gperf doesn't work with datasets with more than 15.000 keys.\n");
|
||||
free (name);
|
||||
free (cname);
|
||||
return -1;
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (mo->format) {
|
||||
case zero:
|
||||
fflush (stdout);
|
||||
write_null ();
|
||||
break;
|
||||
case perf:
|
||||
case cgen:
|
||||
cgen_footer (mo, name, cname);
|
||||
break;
|
||||
case json:
|
||||
printf ("}\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (ret == 0) {
|
||||
switch (mo->format) {
|
||||
case zero:
|
||||
fflush (stdout);
|
||||
ret = write_null ();
|
||||
break;
|
||||
case perf:
|
||||
case cgen:
|
||||
cgen_footer (mo, name, cname);
|
||||
break;
|
||||
case json:
|
||||
printf ("}\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
sdb_free (db);
|
||||
free (cname);
|
||||
free (name);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int insertkeys(Sdb *s, const char **args, int nargs, int mode) {
|
||||
@ -667,8 +670,7 @@ static int base64decode(void) {
|
||||
int declen;
|
||||
out = sdb_decode (in, &declen);
|
||||
if (out && declen >= 0) {
|
||||
(void)write (1, out, declen);
|
||||
ret = 0;
|
||||
ret = (write (1, out, declen) == declen)? 0: 1;
|
||||
}
|
||||
free (out);
|
||||
free (in);
|
||||
@ -759,6 +761,8 @@ static int gen_gperf(MainOptions *mo, const char *file, const char *name) {
|
||||
wd = open (out, O_RDWR | O_CREAT, 0644);
|
||||
} else {
|
||||
if (ftruncate (wd, 0) == -1) {
|
||||
free (out);
|
||||
free (buf);
|
||||
close (wd);
|
||||
return -1;
|
||||
}
|
||||
@ -811,7 +815,7 @@ static int gen_gperf(MainOptions *mo, const char *file, const char *name) {
|
||||
|
||||
static const char *main_argparse_getarg(MainOptions *mo) {
|
||||
int cur = mo->argi;
|
||||
if (mo->argi + 1>= mo->argc) {
|
||||
if (mo->argi + 1 >= mo->argc) {
|
||||
return NULL;
|
||||
}
|
||||
mo->argi++;
|
||||
@ -1010,7 +1014,7 @@ int main(int argc, const char **argv) {
|
||||
save |= sdb_query (s, mo->argv[i]);
|
||||
if (mo->format) {
|
||||
fflush (stdout);
|
||||
write_null ();
|
||||
ret = write_null ();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1021,7 +1025,7 @@ int main(int argc, const char **argv) {
|
||||
save |= sdb_query (s, line);
|
||||
if (mo->format) {
|
||||
fflush (stdout);
|
||||
write_null ();
|
||||
ret = write_null ();
|
||||
}
|
||||
free (line);
|
||||
}
|
||||
@ -1049,7 +1053,7 @@ int main(int argc, const char **argv) {
|
||||
save |= sdb_query (s, mo->argv[i]);
|
||||
if (mo->format) {
|
||||
fflush (stdout);
|
||||
write_null ();
|
||||
ret = write_null ();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -19,7 +19,7 @@ static bool sdb_ht_internal_insert(HtPP* ht, const char* key, const char* value,
|
||||
if (!ht || !key || !value) {
|
||||
return false;
|
||||
}
|
||||
SdbKv kvp = {{0}};
|
||||
SdbKv kvp = {{ 0 }};
|
||||
kvp.base.key = strdup (key);
|
||||
if (!kvp.base.key) {
|
||||
goto err;
|
||||
|
Loading…
Reference in New Issue
Block a user