mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-31 10:22:37 +00:00
Fix all Warnings for GCC 9 (#16223)
This commit is contained in:
parent
66ed0133e2
commit
0eb98d24be
@ -67,27 +67,6 @@ static const char* cmask32(const char *mb_c, const char *me_c) {
|
||||
return cmask;
|
||||
}
|
||||
|
||||
static const char *getreg(struct Getarg *gop, int n) {
|
||||
cs_insn *insn = gop->insn;
|
||||
csh handle = gop->handle;
|
||||
|
||||
if (n < 0 || n >= 8) {
|
||||
return NULL;
|
||||
}
|
||||
cs_ppc_op op = INSOP (n);
|
||||
switch (op.type) {
|
||||
case PPC_OP_REG:
|
||||
return cs_reg_name (handle, op.reg);
|
||||
case PPC_OP_MEM:
|
||||
return cs_reg_name (handle, op.mem.base);
|
||||
case PPC_OP_INVALID:
|
||||
case PPC_OP_IMM:
|
||||
case PPC_OP_CRX: // Condition Register field
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *getarg2(struct Getarg *gop, int n, const char *setstr) {
|
||||
cs_insn *insn = gop->insn;
|
||||
csh handle = gop->handle;
|
||||
@ -223,7 +202,6 @@ static void opex(RStrBuf *buf, csh handle, cs_insn *insn) {
|
||||
#define PPCSPR(n) getspr(&gop, n)
|
||||
#define ARG(n) getarg2(&gop, n, "")
|
||||
#define ARG2(n,m) getarg2(&gop, n, m)
|
||||
#define REG2(n) getreg(&gop, n)
|
||||
|
||||
static int set_reg_profile(RAnal *anal) {
|
||||
const char *p = NULL;
|
||||
|
@ -67,62 +67,6 @@ static int r_bin_dmp64_init_header(struct r_bin_dmp64_obj_t *obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static int findPage(const dmp_page_desc *a, const dmp_page_desc *b) {
|
||||
return a && b &&
|
||||
a->start >= b->start &&
|
||||
a->start < (b->start + PAGE_SIZE) ? 0 : 1;
|
||||
}
|
||||
|
||||
static ut64 read_pte(struct r_bin_dmp64_obj_t *obj, ut64 vaddr) {
|
||||
ut64 res = 0;
|
||||
dmp_page_desc *target = R_NEW0 (dmp_page_desc);
|
||||
target->start = vaddr;
|
||||
RListIter *target_iter = r_list_find (obj->pages, target, (RListComparator)findPage);
|
||||
if (target_iter) {
|
||||
dmp_page_desc *page = r_list_iter_get_data (target_iter);
|
||||
res = r_buf_read_le64_at (obj->b, page->file_offset + vaddr - page->start);
|
||||
} else {
|
||||
eprintf ("Warning: Page not present in the dump file.\n");
|
||||
}
|
||||
free (target);
|
||||
return res;
|
||||
}
|
||||
|
||||
static ut64 vtop(struct r_bin_dmp64_obj_t *obj, ut64 vaddr) {
|
||||
ut64 pml4e_addr = (obj->dtb & 0xffffffffff000) |
|
||||
((vaddr & 0xff8000000000) >> 36);
|
||||
ut64 pml4e_value = read_pte (obj, pml4e_addr);
|
||||
if (!(pml4e_value & 1)) {
|
||||
eprintf ("Warning: Invalid PML4E\n");
|
||||
return 0;
|
||||
}
|
||||
ut64 pdpte_addr = ((pml4e_value & 0xffffffffff000) |
|
||||
((vaddr & 0x7FC0000000) >> 27));
|
||||
ut64 pdpte_value = read_pte (obj, pdpte_addr);
|
||||
if (!(pdpte_value & 1)) {
|
||||
eprintf ("Warning: Invalid PDPTE\n");
|
||||
return 0;
|
||||
}
|
||||
ut64 pde_addr = ((pdpte_value & 0xffffffffff000) |
|
||||
((vaddr & 0x3fe00000) >> 18));
|
||||
ut64 pde_value = read_pte (obj, pde_addr);
|
||||
if (!(pde_value & 1)) {
|
||||
eprintf ("Warning: Invalid PDE\n");
|
||||
return 0;
|
||||
}
|
||||
ut64 pte_addr = (pde_value & 0xffffffffff000) |
|
||||
((vaddr & 0x1ff000) >> 9);
|
||||
ut64 pte_value = read_pte (obj, pte_addr);
|
||||
if (!(pte_value & 1)) {
|
||||
eprintf ("Warning: Invalid PTE\n");
|
||||
return 0;
|
||||
}
|
||||
ut64 paddr = (pte_value & 0xffffffffff000) |
|
||||
(vaddr & 0xfff);
|
||||
|
||||
return paddr;
|
||||
}
|
||||
|
||||
static int r_bin_dmp64_init_bmp_pages(struct r_bin_dmp64_obj_t *obj) {
|
||||
int i;
|
||||
if (!obj->bmp_header) {
|
||||
|
@ -405,7 +405,7 @@ static void cmd_write_op (RCore *core, const char *input) {
|
||||
case 'D': // "wopD"
|
||||
{
|
||||
char *sp = strchr (input, ' ');
|
||||
len = (int)(sp)? r_num_math (core->num, sp + 1): core->blocksize;
|
||||
len = sp? r_num_math (core->num, sp + 1): core->blocksize;
|
||||
}
|
||||
if (len > 0) {
|
||||
/* XXX This seems to fail at generating long patterns (wopD 512K) */
|
||||
|
@ -83,7 +83,7 @@ R_API int r_debug_reg_sync(RDebug *dbg, int type, int write) {
|
||||
}
|
||||
|
||||
R_API int r_debug_reg_list(RDebug *dbg, int type, int size, int rad, const char *use_color) {
|
||||
int delta, from, to, cols, n = 0;
|
||||
int delta, cols, n = 0;
|
||||
const char *fmt, *fmt2, *kwhites;
|
||||
RPrint *pr = NULL;
|
||||
int colwidth = 20;
|
||||
@ -125,8 +125,6 @@ R_API int r_debug_reg_list(RDebug *dbg, int type, int size, int rad, const char
|
||||
}
|
||||
// with the new field "arena" into reg items why need
|
||||
// to get all arenas.
|
||||
from = 0;
|
||||
to = R_REG_TYPE_LAST;
|
||||
|
||||
int itmidx = -1;
|
||||
dbg->creg = NULL;
|
||||
|
@ -91,7 +91,7 @@ R_API RList *r_w32_dbg_maps(RDebug *);
|
||||
/* begin of debugger code */
|
||||
#if DEBUGGER
|
||||
|
||||
#if !__WINDOWS__ || (!__APPLE__ && defined(WAIT_ON_ALL_CHILDREN))
|
||||
#if !__WINDOWS__ && !(__linux__ && !defined(WAIT_ON_ALL_CHILDREN))
|
||||
static int r_debug_handle_signals(RDebug *dbg) {
|
||||
#if __KFBSD__
|
||||
return bsd_handle_signals (dbg);
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define R2_VECTOR_H
|
||||
|
||||
#include <r_types.h>
|
||||
#include <r_util/r_assert.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -69,6 +70,7 @@ R_API void r_vector_free(RVector *vec);
|
||||
R_API RVector *r_vector_clone(RVector *vec);
|
||||
|
||||
static inline bool r_vector_empty(const RVector *vec) {
|
||||
r_return_val_if_fail (vec, false);
|
||||
return vec->len == 0;
|
||||
}
|
||||
|
||||
@ -122,11 +124,11 @@ R_API void *r_vector_shrink(RVector *vec);
|
||||
* }
|
||||
*/
|
||||
#define r_vector_foreach(vec, it) \
|
||||
if ((vec) && (vec)->a) \
|
||||
if (!r_vector_empty (vec)) \
|
||||
for (it = (void *)(vec)->a; (char *)it != (char *)(vec)->a + ((vec)->len * (vec)->elem_size); it = (void *)((char *)it + (vec)->elem_size))
|
||||
|
||||
#define r_vector_enumerate(vec, it, i) \
|
||||
if ((vec) && (vec)->a) \
|
||||
if (!r_vector_empty (vec)) \
|
||||
for (it = (void *)(vec)->a, i = 0; i < (vec)->len; it = (void *)((char *)it + (vec)->elem_size), i++)
|
||||
|
||||
|
||||
|
@ -219,6 +219,7 @@ static void trace_me (void) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __APPLE__ && !__POWERPC__
|
||||
static void handle_posix_error(int err) {
|
||||
switch (err) {
|
||||
case 0:
|
||||
@ -236,6 +237,7 @@ static void handle_posix_error(int err) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static RRunProfile* _get_run_profile(RIO *io, int bits, char **argv) {
|
||||
char *expr = NULL;
|
||||
|
@ -122,7 +122,7 @@ struct grub_hfsplus_catkey
|
||||
grub_uint16_t keylen;
|
||||
grub_uint32_t parent;
|
||||
grub_uint16_t namelen;
|
||||
grub_uint16_t name[30];
|
||||
grub_unaligned_uint16_t name[30];
|
||||
});
|
||||
|
||||
/* The on disk layout of an extent overflow file key. */
|
||||
|
@ -147,7 +147,7 @@ struct grub_jfs_leaf_dirent
|
||||
|
||||
/* The size of the name. */
|
||||
grub_uint8_t len;
|
||||
grub_uint16_t namepart[11];
|
||||
grub_unaligned_uint16_t namepart[11];
|
||||
grub_uint32_t index;
|
||||
});
|
||||
|
||||
@ -159,7 +159,7 @@ struct grub_jfs_leaf_next_dirent
|
||||
{
|
||||
grub_uint8_t next;
|
||||
grub_uint8_t len;
|
||||
grub_uint16_t namepart[15];
|
||||
grub_unaligned_uint16_t namepart[15];
|
||||
});
|
||||
|
||||
R_PACKED (
|
||||
|
@ -84,7 +84,7 @@ struct grub_xfs_dir2_entry
|
||||
grub_uint8_t len;
|
||||
});
|
||||
|
||||
typedef grub_uint32_t grub_xfs_extent[4];
|
||||
typedef grub_unaligned_uint32_t grub_xfs_extent[4];
|
||||
|
||||
R_PACKED (
|
||||
struct grub_xfs_btree_node
|
||||
@ -102,7 +102,7 @@ struct grub_xfs_btree_root
|
||||
{
|
||||
grub_uint16_t level;
|
||||
grub_uint16_t numrecs;
|
||||
grub_uint64_t keys[1];
|
||||
grub_unaligned_uint64_t keys[1];
|
||||
});
|
||||
|
||||
R_PACKED (
|
||||
@ -248,7 +248,7 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
|
||||
|
||||
if (node->inode.format == XFS_INODE_FORMAT_BTREE)
|
||||
{
|
||||
grub_uint64_t *keys;
|
||||
grub_unaligned_uint64_t *keys;
|
||||
|
||||
leaf = grub_malloc (node->data->sblock.bsize);
|
||||
if (leaf == 0)
|
||||
@ -555,11 +555,11 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
|
||||
- (int) sizeof (struct grub_xfs_dir2_entry)))
|
||||
{
|
||||
struct grub_xfs_dir2_entry *direntry;
|
||||
grub_uint16_t *freetag;
|
||||
grub_unaligned_uint16_t *freetag;
|
||||
char *filename;
|
||||
|
||||
direntry = (struct grub_xfs_dir2_entry *) &dirblock[pos];
|
||||
freetag = (grub_uint16_t *) direntry;
|
||||
freetag = (grub_unaligned_uint16_t *) direntry;
|
||||
|
||||
if (*freetag == 0XFFFF)
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ grub_utf8_to_utf16 (grub_uint16_t *dest, grub_size_t destsize,
|
||||
|
||||
/* Convert UTF-16 to UTF-8. */
|
||||
static inline grub_uint8_t *
|
||||
grub_utf16_to_utf8 (grub_uint8_t *dest, grub_uint16_t *src,
|
||||
grub_utf16_to_utf8 (grub_uint8_t *dest, grub_unaligned_uint16_t *src,
|
||||
grub_size_t size)
|
||||
{
|
||||
grub_uint32_t code_high = 0;
|
||||
|
@ -33,7 +33,11 @@ struct grub_hfs_extent
|
||||
};
|
||||
|
||||
/* HFS stores extents in groups of 3. */
|
||||
typedef struct grub_hfs_extent grub_hfs_datarecord_t[3];
|
||||
typedef struct grub_hfs_extent grub_hfs_datarecord_t[3]
|
||||
#ifdef __GNUC__
|
||||
__attribute__((aligned(1)))
|
||||
#endif
|
||||
;
|
||||
|
||||
/* The HFS superblock (The official name is `Master Directory
|
||||
Block'). */
|
||||
|
@ -119,6 +119,16 @@ typedef grub_uint64_t grub_off_t;
|
||||
/* The type for representing a disk block address. */
|
||||
typedef grub_uint64_t grub_disk_addr_t;
|
||||
|
||||
#ifdef __GNUC__
|
||||
typedef grub_uint64_t grub_unaligned_uint64_t __attribute__((aligned(1)));
|
||||
typedef grub_uint32_t grub_unaligned_uint32_t __attribute__((aligned(1)));
|
||||
typedef grub_uint16_t grub_unaligned_uint16_t __attribute__((aligned(1)));
|
||||
#else
|
||||
typedef grub_uint64_t grub_unaligned_uint64_t;
|
||||
typedef grub_uint32_t grub_unaligned_uint32_t;
|
||||
typedef grub_uint16_t grub_unaligned_uint16_t;
|
||||
#endif
|
||||
|
||||
/* Byte-orders. */
|
||||
#ifdef _MSC_VER
|
||||
__inline grub_uint16_t grub_swap_bytes16 (grub_uint16_t x)
|
||||
|
@ -75,7 +75,7 @@ struct grub_partition_map grub_sun_partition_map;
|
||||
static int
|
||||
grub_sun_is_valid (struct grub_sun_block *label)
|
||||
{
|
||||
grub_uint16_t *pos;
|
||||
grub_unaligned_uint16_t *pos;
|
||||
grub_uint16_t sum = 0;
|
||||
|
||||
for (pos = (grub_uint16_t *) label;
|
||||
|
@ -56,7 +56,7 @@ struct grub_partition_map grub_sun_pc_partition_map;
|
||||
static int
|
||||
grub_sun_is_valid (struct grub_sun_pc_block *label)
|
||||
{
|
||||
grub_uint16_t *pos;
|
||||
grub_unaligned_uint16_t *pos;
|
||||
grub_uint16_t sum = 0;
|
||||
|
||||
for (pos = (grub_uint16_t *) label;
|
||||
|
@ -52,7 +52,7 @@ bool test_r_anal_function_relocate() {
|
||||
assert_invariants (anal);
|
||||
RAnalFunction *fb = r_anal_create_function (anal, "do_something_else", 0xdeadbeef, 0, NULL);
|
||||
assert_invariants (anal);
|
||||
RAnalFunction *fc = r_anal_create_function (anal, "do_something_different", 0xc0ffee, 0, NULL);
|
||||
r_anal_create_function (anal, "do_something_different", 0xc0ffee, 0, NULL);
|
||||
assert_invariants (anal);
|
||||
|
||||
bool success = r_anal_function_relocate (fa, fb->addr);
|
||||
|
@ -299,7 +299,6 @@ bool test_r_buf_format(void) {
|
||||
}
|
||||
|
||||
bool test_r_buf_with_buf(void) {
|
||||
char filename[] = "r2-XXXXXX";
|
||||
const char *content = "Something To\nSay Here..";
|
||||
const int length = 23;
|
||||
RBuffer *buf = r_buf_new_with_bytes ((ut8 *)content, length);
|
||||
@ -318,7 +317,6 @@ bool test_r_buf_with_buf(void) {
|
||||
}
|
||||
|
||||
bool test_r_buf_slice(void) {
|
||||
char filename[] = "r2-XXXXXX";
|
||||
const char *content = "AAAAAAAAAASomething To\nSay Here..BBBBBBBBBB";
|
||||
const int length = strlen (content);
|
||||
RBuffer *buf = r_buf_new_with_bytes ((ut8 *)content, length);
|
||||
|
Loading…
x
Reference in New Issue
Block a user