mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-28 07:30:33 +00:00
Fix lot of warnings
This commit is contained in:
parent
b889dd5e8d
commit
b49195f2df
@ -110,7 +110,7 @@ eprintf ("-- %s\n", buf);
|
||||
}
|
||||
case 'C': /* comment */
|
||||
if (input[1] == '+') {
|
||||
char *text, *newcomment = input+2;
|
||||
const char *text, *newcomment = input+2;
|
||||
while (*newcomment==' ') newcomment++;
|
||||
char *comment = r_meta_get_string (
|
||||
core->anal, R_META_TYPE_COMMENT, addr);
|
||||
|
@ -407,7 +407,7 @@ static int pdi(RCore *core, int l, int len, int ilen) {
|
||||
r_cons_printf ("%16s ", asmop.buf_hex);
|
||||
if (decode || esil) {
|
||||
RAnalOp analop = {0};
|
||||
char *tmpopstr, *opstr;
|
||||
char *tmpopstr, *opstr = NULL;
|
||||
r_anal_op (core->anal, &analop, core->offset+i,
|
||||
buf+i, core->blocksize-i);
|
||||
tmpopstr = r_anal_op_to_string (core->anal, &analop);
|
||||
|
@ -645,7 +645,6 @@ static int cb_binminstr(void *user, void *data) {
|
||||
}
|
||||
|
||||
static int cb_searchin(void *user, void *data) {
|
||||
RCore *core = (RCore*) user;
|
||||
RConfigNode *node = (RConfigNode*) data;
|
||||
if (*node->value == '?') {
|
||||
r_cons_printf ("raw\nblock\nfile\nsection\n");
|
||||
@ -655,7 +654,6 @@ static int cb_searchin(void *user, void *data) {
|
||||
}
|
||||
|
||||
static int cb_fileloadmethod(void *user, void *data) {
|
||||
RCore *core = (RCore*) user;
|
||||
RConfigNode *node = (RConfigNode*) data;
|
||||
if (*node->value == '?') {
|
||||
r_cons_printf ("fail\noverwrite\nappend\n");
|
||||
@ -680,8 +678,6 @@ R_API int r_core_config_init(RCore *core) {
|
||||
SETPREF("anal.prelude", "", "Specify an hexpair to find preludes in code");
|
||||
SETCB("anal.split", "true", &cb_analsplit, "Split functions into basic blocks in analysis.");
|
||||
SETI("anal.ptrdepth", 3, "Maximum number of nested pointers to follow in analysis");
|
||||
SETCB("search.in", "file", &cb_searchin, "Specify search boundaries (raw, block, file, section)");
|
||||
SETCB("file.loadmethod", "fail", &cb_searchin, "What to do when load addresses overlap: fail, overwrite, or append (next available)");
|
||||
|
||||
/* asm */
|
||||
//asm.os needs to be first, since other asm.* depend on it
|
||||
@ -910,7 +906,7 @@ R_API int r_core_config_init(RCore *core) {
|
||||
SETI("search.distance", 0, "Search string distance");
|
||||
SETPREF("search.flags", "true", "If enabled all search results are flagged, else just printed r2 commands");
|
||||
SETI("search.from", -1, "Search start address");
|
||||
SETPREF("search.in", "file", "Specify search boundaries (raw, block, file, section)");
|
||||
SETCB("search.in", "file", &cb_searchin, "Specify search boundaries (raw, block, file, section)");
|
||||
SETI("search.kwidx", 0, "Store last search index count");
|
||||
SETPREF("search.prefix", "hit", "Prefix name in search hits label");
|
||||
SETPREF("search.show", "true", "Show search results while found (disable if lot of hits)");
|
||||
@ -933,7 +929,7 @@ R_API int r_core_config_init(RCore *core) {
|
||||
SETPREF("file.project", "", "Name of current project");
|
||||
SETPREF("file.sha1", "", "sha1 hash of current file");
|
||||
SETPREF("file.type", "", "Type of current file");
|
||||
SETPREF("file.loadmethod", "fail", "What to do when load addresses overlap: fail, overwrite, or append (next available)");
|
||||
SETCB("file.loadmethod", "fail", &cb_fileloadmethod, "What to do when load addresses overlap: fail, overwrite, or append (next available)");
|
||||
SETI("file.loadalign", 1024, "Alignment of load addresses");
|
||||
SETPREF("file.nowarn", "true", "Suppress file loading warning messages if true");
|
||||
SETPREF("file.location", "", "Is the file 'local', 'remote', or 'memory'");
|
||||
|
@ -8,8 +8,10 @@
|
||||
#include <string.h>
|
||||
#include <r_anal.h>
|
||||
|
||||
#undef UNUSED
|
||||
|
||||
#undef R_API
|
||||
#define R_API static
|
||||
#define R_API static inline
|
||||
#undef R_IPI
|
||||
#define R_IPI static
|
||||
|
||||
@ -396,9 +398,11 @@ static int r_cmd_java_handle_summary_info (RCore *core, const char *cmd) {
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
#if UNUSED
|
||||
static int r_cmd_java_check_op_idx (const ut8 *op_bytes, ut16 idx) {
|
||||
return R_BIN_JAVA_USHORT (op_bytes, 0) == idx;
|
||||
}
|
||||
#endif
|
||||
|
||||
static RList * r_cmd_java_handle_find_cp_value_double (RCore *core, RBinJavaObj *obj, const char *cmd) {
|
||||
double value = cmd && *cmd ? strtod (cmd, NULL) : 0.0;
|
||||
@ -1514,6 +1518,7 @@ static int r_cmd_java_print_field_num_name (RBinJavaObj *obj) {
|
||||
}
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
static int r_cmd_java_print_method_num_name (RBinJavaObj *obj) {
|
||||
RList * the_list = r_bin_java_get_method_num_name (obj);
|
||||
char * str;
|
||||
@ -1523,6 +1528,7 @@ static int r_cmd_java_print_method_num_name (RBinJavaObj *obj) {
|
||||
}
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
static int r_cmd_java_print_field_summary (RBinJavaObj *obj, ut16 idx) {
|
||||
int res = r_bin_java_print_field_idx_summary (obj, idx);
|
||||
if (res == R_FALSE) {
|
||||
@ -1531,12 +1537,15 @@ static int r_cmd_java_print_field_summary (RBinJavaObj *obj, ut16 idx) {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
#if UNUSED
|
||||
static int r_cmd_java_print_field_count (RBinJavaObj *obj) {
|
||||
ut32 res = r_bin_java_get_field_count (obj);
|
||||
r_cons_printf ("%d\n", res);
|
||||
r_cons_flush();
|
||||
return R_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int r_cmd_java_print_field_name (RBinJavaObj *obj, ut16 idx) {
|
||||
char * res = r_bin_java_get_field_name (obj, idx);
|
||||
@ -1611,7 +1620,6 @@ static char * r_cmd_java_get_descriptor (RCore *core, RBinJavaObj *bin, ut16 idx
|
||||
return prototype;
|
||||
}
|
||||
|
||||
|
||||
static int r_cmd_java_handle_list_code_references (RCore *core, const char *input) {
|
||||
RAnal *anal = get_anal (core);
|
||||
RBinJavaObj *bin = anal ? (RBinJavaObj *) r_cmd_java_get_bin_obj (anal) : NULL;
|
||||
|
@ -44,7 +44,7 @@ static int timeout = 0;
|
||||
|
||||
static int r_cmd_yara_call(void *user, const char *input);
|
||||
static int r_cmd_yara_init(void *user, const char *input);
|
||||
static int r_cmd_yara_process(const RCore* core, const char* input);
|
||||
static int r_cmd_yara_process(RCore* core, const char* input);
|
||||
static int callback(int message, YR_RULE* rule, void* data);
|
||||
|
||||
static int callback (int message, YR_RULE* rule, void* data) {
|
||||
@ -68,7 +68,7 @@ static int callback (int message, YR_RULE* rule, void* data) {
|
||||
return CALLBACK_CONTINUE;
|
||||
}
|
||||
|
||||
static int r_cmd_yara_process(const RCore* core, const char* input) {
|
||||
static int r_cmd_yara_process(RCore* core, const char* input) {
|
||||
YR_RULES* rules;
|
||||
YR_COMPILER* compiler;
|
||||
FILE* rules_file;
|
||||
@ -145,7 +145,7 @@ static int r_cmd_yara_process(const RCore* core, const char* input) {
|
||||
}
|
||||
|
||||
static int r_cmd_yara_call(void *user, const char *input) {
|
||||
const RCore* core = (RCore*) user;
|
||||
RCore* core = (RCore*) user;
|
||||
if (!strncmp (input, "yara", 4)) {
|
||||
const char *args = input+4;
|
||||
if (!r_yr_initialize)
|
||||
@ -159,7 +159,6 @@ static int r_cmd_yara_call(void *user, const char *input) {
|
||||
}
|
||||
|
||||
static int r_cmd_yara_init(void *user, const char *input) {
|
||||
const RCore* core = (RCore*) user;
|
||||
void *libyara = r_lib_dl_open ("libyara."R_LIB_EXT);
|
||||
if (!libyara) {
|
||||
eprintf ("Cannot find libyara\n");
|
||||
|
@ -958,6 +958,8 @@ R_API int r_anal_fcn_local_del_index(RAnal *anal, RAnalFunction *fcn, ut32 index
|
||||
#define r_anal_fcn_local_del_index(x,y,z) r_anal_fcn_var_del_byindex(x, y,\
|
||||
R_ANAL_FCN_VARKIND_LOCAL, z)
|
||||
#define r_anal_fcn_local_del_name(x,y,z) error
|
||||
|
||||
R_API int r_anal_fcn_var_del_bydelta (RAnal *a, ut64 fna, const char kind, int scope, ut32 delta);
|
||||
R_API int r_anal_fcn_var_add (RAnal *a, ut64 fna, const char kind,
|
||||
int scope, ut32 idx, const char *name, const char *type);
|
||||
R_API int r_anal_fcn_var_del_byindex (RAnal *a, ut64 fna, const char kind,
|
||||
|
@ -280,6 +280,7 @@ R_API void r_io_map_init(RIO *io);
|
||||
R_API ut64 r_io_map_next(RIO *io, ut64 addr);
|
||||
R_API RIOMap *r_io_map_add(RIO *io, int fd, int flags, ut64 delta, ut64 offset, ut64 size);
|
||||
R_API int r_io_map_del_at(RIO *io, ut64 addr);
|
||||
R_API RIOMap *r_io_map_get(RIO *io, ut64 addr);
|
||||
R_API RIOMap *r_io_map_get_global(RIO *io, ut64 addr);
|
||||
R_API RIOMap *r_io_map_get_local(RIO *io, ut64 addr, int fd);
|
||||
R_API int r_io_map_del(RIO *io, int fd);
|
||||
|
@ -59,7 +59,7 @@ R_API RIODesc *r_io_desc_new(RIOPlugin *plugin, int fd, const char *name, int fl
|
||||
R_API void r_io_desc_free(RIODesc *desc) {
|
||||
if (!desc) return;
|
||||
if (desc->io) {
|
||||
const RIO * io = desc->io;
|
||||
RIO* io = (RIO*)desc->io;
|
||||
desc->io = NULL;
|
||||
r_io_close (io, desc);
|
||||
}
|
||||
|
@ -9,10 +9,6 @@ R_LIB_VERSION (r_io);
|
||||
#define DO_THE_IO_DBG 0
|
||||
#define IO_IFDBG if (DO_THE_IO_DBG == 1)
|
||||
|
||||
static int r_io_insert_adapted(RIO *io, ut64 offset, ut64 size);
|
||||
// TODO: R_API int r_io_fetch(struct r_io_t *io, ut8 *buf, int len)
|
||||
// --- check for EXEC perms in section (use cached read to accelerate)
|
||||
|
||||
R_API RIO *r_io_new() {
|
||||
RIO *io = R_NEW (RIO);
|
||||
if (!io) return NULL;
|
||||
|
@ -39,17 +39,19 @@ static int debug_gdb_read_at(ut8 *buf, int sz, ut64 addr) {
|
||||
}
|
||||
|
||||
|
||||
static int debug_gdb_write_at(ut8 *buf, int sz, ut64 addr) {
|
||||
static int debug_gdb_write_at(const ut8 *buf, int sz, ut64 addr) {
|
||||
ut32 size_max = 500;
|
||||
ut32 packets = sz / size_max;
|
||||
ut32 last = sz % size_max;
|
||||
ut32 x;
|
||||
if (sz < 1 || addr >= UT64_MAX) return -1;
|
||||
for (x = 0; x < packets; x++) {
|
||||
gdbr_write_memory(desc, addr + x * size_max, (buf + x * size_max), size_max);
|
||||
gdbr_write_memory (desc, addr + x * size_max,
|
||||
(const uint8_t*)(buf + x * size_max), size_max);
|
||||
}
|
||||
if (last) {
|
||||
gdbr_write_memory(desc, addr + x * size_max, (buf + x * size_max), last);
|
||||
gdbr_write_memory (desc, addr + x * size_max,
|
||||
(buf + x * size_max), last);
|
||||
}
|
||||
|
||||
return sz;
|
||||
|
@ -62,7 +62,7 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
|
||||
eprintf ("task_for_pid failed\n");
|
||||
return NULL;
|
||||
}
|
||||
macosx_debug_regions (task, (void*)(size_t)1, 1000);
|
||||
macosx_debug_regions (task, (size_t)1, 1000);
|
||||
io->va = R_TRUE; // nop
|
||||
return r_io_desc_new (&r_io_plugin_self,
|
||||
pid, file, rw, mode, NULL);
|
||||
@ -241,7 +241,8 @@ void macosx_debug_regions (task_t task, mach_vm_address_t address, int max) {
|
||||
|
||||
}
|
||||
if (kret != KERN_SUCCESS) {
|
||||
fprintf (stderr,"mach_vm_region failed for address %p - Error: %x\n", address,(kret));
|
||||
fprintf (stderr,"mach_vm_region failed for address %p - Error: %x\n",
|
||||
(void*)(size_t)address, kret);
|
||||
size = 0;
|
||||
if (address >= 0x4000000) return;
|
||||
print = done = 1;
|
||||
@ -275,8 +276,8 @@ void macosx_debug_regions (task_t task, mach_vm_address_t address, int max) {
|
||||
if (print_size > 1024) { print_size /= 1024; print_size_unit = "G"; }
|
||||
/* End Quick hack */
|
||||
printf (" %p - %p [%d%s](%x/%x; %d, %s, %s)",
|
||||
(prev_address),
|
||||
(prev_address + prev_size),
|
||||
(void*)(size_t)(prev_address),
|
||||
(void*)(size_t)(prev_address + prev_size),
|
||||
print_size,
|
||||
print_size_unit,
|
||||
prev_info.protection,
|
||||
|
@ -60,7 +60,7 @@ R_API int r_print_format(RPrint *p, ut64 seek, const ut8* b, int len, const char
|
||||
int (*oldprintf)(const char *str, ...);
|
||||
const char *argend = fmt+strlen (fmt);
|
||||
ut64 addr = 0, addr64 = 0, seeki = 0;;
|
||||
char *args, *bracket, tmp, last = 0;
|
||||
char *args = NULL, *bracket, tmp, last = 0;
|
||||
const char *arg = fmt;
|
||||
int viewflags = 0;
|
||||
char namefmt[8];
|
||||
|
@ -111,7 +111,7 @@ int gdbr_read_registers(libgdbr_t* instance);
|
||||
int gdbr_write_bin_registers(libgdbr_t* instance, char* registers);
|
||||
int gdbr_write_registers(libgdbr_t* instance, char* registers);
|
||||
int gdbr_read_memory(libgdbr_t* instance, uint64_t address, uint64_t len);
|
||||
int gdbr_write_memory(libgdbr_t* instance, uint64_t address, char* data, uint64_t len);
|
||||
int gdbr_write_memory(libgdbr_t* instance, uint64_t address, const uint8_t* data, uint64_t len);
|
||||
int gdbr_send_command(libgdbr_t* instance, char* command);
|
||||
int test_command(libgdbr_t* instance, char* command);
|
||||
|
||||
|
@ -232,12 +232,13 @@ int gdbr_read_memory(libgdbr_t* g, uint64_t address, uint64_t len) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int gdbr_write_memory(libgdbr_t* g, uint64_t address, char* data, uint64_t len) {
|
||||
int gdbr_write_memory(libgdbr_t* g, uint64_t address, const uint8_t* data, uint64_t len) {
|
||||
char command[255] = {};
|
||||
int command_len = snprintf(command, 255, "%s%016"PFMT64x",%"PFMT64d":", CMD_WRITEMEM, address, len);
|
||||
char* tmp = calloc(command_len + (len * 2), sizeof(char));
|
||||
char* tmp = calloc(command_len + (len * 2), sizeof(ut8));
|
||||
memcpy (tmp, command, command_len);
|
||||
pack_hex (data, len, (tmp + command_len));
|
||||
// XXX: we should
|
||||
pack_hex ((char*)data, len, (tmp + command_len));
|
||||
send_command (g, tmp);
|
||||
free (tmp);
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <stdio.h>
|
||||
#include "zlib.h"
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -3,6 +3,7 @@
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include "gzguts.h"
|
||||
|
||||
#if defined(_WIN32) && !defined(__BORLANDC__)
|
||||
|
Loading…
Reference in New Issue
Block a user