Fix warnings

This commit is contained in:
pancake 2021-05-18 19:34:23 +02:00
parent fb141bdb0d
commit 374037a4d2
4 changed files with 9 additions and 12 deletions

View File

@ -185,8 +185,6 @@ jobs:
uses: actions/checkout@v2
- name: Installing the musl runtime
run: |
sudo apt update
sudo apt upgrade
sudo apt install musl-tools
- name: Building static r2 with acr
run: |

View File

@ -3126,15 +3126,15 @@ static RBinElfSymbol* get_symbols_from_phdr(ELFOBJ *bin, int type) {
for (i = 1, ret_ctr = 0; i < nsym; i++) {
if (i >= capacity1) { // maybe grow
// You take what you want, but you eat what you take.
Elf_(Sym)* temp_sym = (Elf_(Sym)*) realloc (sym, (capacity1 * GROWTH_FACTOR) * sym_size);
Elf_(Sym)* temp_sym = (Elf_(Sym)*) realloc (sym, (size_t)(capacity1 * GROWTH_FACTOR) * sym_size);
if (!temp_sym) {
goto beach;
}
sym = temp_sym;
capacity1 *= GROWTH_FACTOR;
capacity1 = (size_t)(capacity1 * GROWTH_FACTOR);
}
if (ret_ctr >= capacity2) { // maybe grow
RBinElfSymbol *temp_ret = realloc (ret, capacity2 * GROWTH_FACTOR * sizeof (struct r_bin_elf_symbol_t));
RBinElfSymbol *temp_ret = realloc (ret, (size_t)(capacity2 * GROWTH_FACTOR) * sizeof (struct r_bin_elf_symbol_t));
if (!temp_ret) {
goto beach;
}
@ -3223,7 +3223,7 @@ done:
// Size everything down to only what is used
{
nsym = i > 0? i: 1;
Elf_(Sym) *temp_sym = (Elf_(Sym) *)realloc (sym, (nsym * GROWTH_FACTOR) * sym_size);
Elf_(Sym) *temp_sym = (Elf_(Sym) *)realloc (sym, (size_t)(nsym * GROWTH_FACTOR) * sym_size);
if (!temp_sym) {
goto beach;
}

View File

@ -18,7 +18,7 @@ static int wad_header_load(WadObj *wo, Sdb *kv) {
(void) r_buf_fread_at (wo->buf, 0, (ut8 *) hdr, "uuu", 1);
sdb_set (kv, "header.num_lumps", sdb_fmt ("%u", hdr->numlumps), 0);
sdb_set (kv, "header.diroffset", sdb_fmt ("0x%x", hdr->diroffset), 0);
ut32 numlumps = sdb_get (kv, "header.diroffset", 0);
ut32 numlumps = sdb_num_get (kv, "header.diroffset", 0);
eprintf("NumLumps: %x", numlumps);
return true;
}
@ -102,7 +102,7 @@ static RList *symbols(RBinFile *bf) {
while (i < wo->hdr.numlumps) {
memset (&dir, 0, sizeof (dir));
r_buf_read_at (bf->buf, wo->hdr.diroffset + (i * 16), (ut8*)&dir, sizeof (dir));
addsym (ret, strndup(dir.name, 8), dir.filepos, dir.size);
addsym (ret, r_str_ndup (dir.name, 8), dir.filepos, dir.size);
i++;
}
return ret;
@ -118,7 +118,6 @@ static void wad_header_fields(RBinFile *bf) {
}
static RList *wad_fields(RBinFile *bf) {
RBuffer *buf = bf->buf;
RList *ret = r_list_new ();
if (!ret) {
return NULL;

View File

@ -87,9 +87,9 @@ static void render_greyscale(PrintfCallback cb_printf, const ut8 *c, const ut8 *
static void render_ascii(PrintfCallback cb_printf, const ut8 *c, const ut8 *d) {
const char *pal = " `.,-:+*%$#";
int idx, pal_len = strlen (pal);
float p = (c[0]+c[1]+c[2])/3;
float q = (d[0]+d[1]+d[2])/3;
idx = ((p+q)/2) / (255/pal_len);
float p = ((double)(c[0]+c[1]+c[2])/3);
float q = ((double)(d[0]+d[1]+d[2])/3);
idx = (int)(((p+q)/2) / (255/pal_len));
if (idx >= pal_len) idx = pal_len-1;
cb_printf ("%c", pal[idx]);
}