Fix incorrect use of non-const strings and fiz zousans of warnings (#18544)

Co-authored-by: pancake <pancake@nopcode.org>
This commit is contained in:
pancake 2021-04-06 12:45:19 +02:00 committed by GitHub
parent 5a29fa2856
commit 530c737d5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 88 additions and 88 deletions

View File

@ -62,7 +62,7 @@
typedef unsigned int arc_insn;
struct arc_opcode {
char *syntax; /* syntax of insn */
const char *syntax; /* syntax of insn */
unsigned long mask, value; /* recognize insn if (op&mask)==value */
int flags; /* various flag bits */

View File

@ -258,7 +258,7 @@ static ut64 cqcheck(char **input) {
return 0;
}
static ut64 opmask(char *input, char *opcode, ut64 allowed_mask) {
static ut64 opmask(char *input, const char *opcode, ut64 allowed_mask) {
ut64 res = 0;
r_str_case (input, false);

View File

@ -45,7 +45,7 @@ struct arg_t {
static struct opcode_t {
unsigned char cmd;
int size;
char *name;
const char *name;
struct arg_t arg1, arg2;
} opcodes[] = {
{ 0x76, 1, "hlt" },

View File

@ -42,7 +42,7 @@ struct pa_opcode
const char *name;
unsigned long int match; /* Bits that must be set... */
unsigned long int mask; /* ... in these bits. */
char *args;
const char *args;
enum pa_arch arch;
char flags;
};

View File

@ -75,7 +75,7 @@ static sparc_opcode_hash *opcode_hash_table[HASH_SIZE];
((((int)(value)) << ((8 * sizeof (int)) - (bits))) \
>> ((8 * sizeof (int)) - (bits)) )
static char *reg_names[] =
static const char *reg_names[] =
{ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
"o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7",
"l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
@ -96,7 +96,7 @@ static char *reg_names[] =
/* These are ordered according to there register number in
rdpr and wrpr insns. */
static char *v9_priv_reg_names[] =
static const char *v9_priv_reg_names[] =
{
"tpc", "tnpc", "tstate", "tt", "tick", "tba", "pstate", "tl",
"pil", "cwp", "cansave", "canrestore", "cleanwin", "otherwin",
@ -106,7 +106,7 @@ static char *v9_priv_reg_names[] =
/* These are ordered according to there register number in
rdhpr and wrhpr insns. */
static char *v9_hpriv_reg_names[] =
static const char *v9_hpriv_reg_names[] =
{
"hpstate", "htstate", "resv2", "hintp", "resv4", "htba", "hver",
"resv7", "resv8", "resv9", "resv10", "resv11", "resv12", "resv13",
@ -117,7 +117,7 @@ static char *v9_hpriv_reg_names[] =
/* These are ordered according to there register number in
rd and wr insns (-16). */
static char *v9a_asr_reg_names[] =
static const char *v9a_asr_reg_names[] =
{
"pcr", "pic", "dcr", "gsr", "set_softint", "clear_softint",
"softint", "tick_cmpr", "stick", "stick_cmpr"

View File

@ -16,7 +16,7 @@
extern char *ins_str[];
extern ut32 ins_buff_len;
static ut32 get_q_bits(ut32 val, char *ins, ut32 ins_len, int *err_code) {
static ut32 get_q_bits(ut32 val, const char *ins, ut32 ins_len, int *err_code) {
ut32 res = 0;
if (!r_str_ncasecmp (ins, "q_MMAP", 6)) {
@ -53,7 +53,7 @@ static ut32 get_q_bits(ut32 val, char *ins, ut32 ins_len, int *err_code) {
a2 = 0x223;
0x800 = valor que se crea en sub_40BAE0<) con and 0xfffff800
*/
static ut32 get_ins_bits(ut32 hash_code, ut32 ins_pos, char *ins,
static ut32 get_ins_bits(ut32 hash_code, ut32 ins_pos, const char *ins,
ut32 ins_len, ut32 magic_value, int *err_code)
{
ut32 res = 0;
@ -486,7 +486,7 @@ static bool is_linear_circular(ut32 ins_bits) {
return (op == 26 || op == 30 || (op3 > 7 && op3 != 15));
}
static char* get_token_decoded(st32 hash_code, char *ins_token, ut32 ins_token_len,
static char* get_token_decoded(st32 hash_code, const char *ins_token, ut32 ins_token_len,
char *reg_arg, ut32 *ret_ins_bits, ut32 *ret_reg_len, ut32 magic_value,
ut32 ins_pos, ut32 ins_len, ut8 two_ins, int *err_code) {
ut32 tok_op, ins_bits;

View File

@ -11,15 +11,15 @@ static bool is_linear_circular(ut32 ins_bits);
static bool is_hash(st32 hash_code);
static bool check_arg(ut32 ins_bits, int *err_code);
static ut32 get_ins_bits(ut32 hash_code, ut32 ins_pos, char *ins, ut32 ins_len, ut32 magic_value, int *err_code);
static ut32 get_q_bits(ut32 val, char *ins, ut32 ins_len, int *err_code);
static ut32 get_ins_bits(ut32 hash_code, ut32 ins_pos, const char *ins, ut32 ins_len, ut32 magic_value, int *err_code);
static ut32 get_q_bits(ut32 val, const char *ins, ut32 ins_len, int *err_code);
static char *do_decode(ut32 ins_off, ut32 ins_pos, ut32 two_ins, ut32 *next_ins_pos, st32 *ins_hash_code, int *err_code);
static char *decode_ins(st32 hash_code, ut32 ins_pos, ut32 ins_off, ut32 *ins_len_dec, ut32 *reg_len_dec, ut32 *ret_ins_bits, ut32 magic_value, ut8 two_ins, int *err_code);
static char *decode_regis(char *reg_arg, st32 hash_code, ut32 ins_bits, ut32 *ret_ins_bits, int *err_code);
static char* get_token_decoded(st32 hash_code, char *ins_token, ut32 ins_token_len, char *reg_arg, ut32 *ret_ins_bits, ut32 *ret_reg_len, ut32 magic_value, ut32 ins_pos, ut32 ins_len, ut8 two_ins, int *err_code);
static char* get_token_decoded(st32 hash_code, const char *ins_token, ut32 ins_token_len, char *reg_arg, ut32 *ret_ins_bits, ut32 *ret_reg_len, ut32 magic_value, ut32 ins_pos, ut32 ins_len, ut8 two_ins, int *err_code);
#endif

View File

@ -19,8 +19,8 @@ enum {
Z80_ENC1 = 128
};
typedef struct{
char* name;
typedef struct {
const char* name;
int type;
const void *op_moar;
} z80_opcode;

View File

@ -25,7 +25,7 @@ enum {
NRM_NRM
};
static char* utf8_line_vert (int dot_style) {
static const char* utf8_line_vert (int dot_style) {
if (r_cons_singleton ()->dotted_lines) {
switch (dot_style) {
case DOT_STYLE_NORMAL: return RUNECODESTR_LINE_VERT;
@ -36,7 +36,7 @@ static char* utf8_line_vert (int dot_style) {
return RUNECODESTR_LINE_VERT;
}
static char* utf8_line_horiz (int dot_style) {
static const char* utf8_line_horiz (int dot_style) {
if (r_cons_singleton ()->dotted_lines) {
switch (dot_style) {
case DOT_STYLE_NORMAL: return RUNECODESTR_LINE_HORIZ;

View File

@ -20,8 +20,8 @@ static int replace(int argc, const char *argv[], char *newstr, ADDR_TYPE type) {
int i, j, k;
struct {
int narg;
char *op;
char *str;
const char *op;
const char *str;
} ops[] = {
{1, "lda", "a = 1"},
{2, "lda", "a = (1+2)"},

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2015-2018 - pancake */
/* radare - LGPL - Copyright 2015-2021 - pancake */
#include <stdio.h>
#include <stdlib.h>
@ -15,8 +15,8 @@ static int replace(int argc, const char *argv[], char *newstr) {
char ch;
struct {
int narg;
char *op;
char *str;
const char *op;
const char *str;
int args[MAXPSEUDOOPS];
} ops[] = {
{ 0, "abs", "# = abs(#)", { 1, 1 } },

View File

@ -13,8 +13,8 @@
static int replace(int argc, const char *argv[], char *newstr) {
int i,j,k;
struct {
char *op;
char *str;
const char *op;
const char *str;
} ops[] = {
{ "cmpl", "cmp 2, 1"},
{ "testl", "test 2, 1"},

View File

@ -13,8 +13,8 @@
static bool replace(int argc, const char *argv[], char *newstr) {
int i,j,k;
struct {
char *op;
char *str;
const char *op;
const char *str;
} ops[] = {
{ "add", "A += B"},
{ "adc", "A += B + carry"},

View File

@ -9,8 +9,8 @@
#define MAXARGS 4
#define BUFSIZE 64
static void concat(char *buf, size_t len, char** args) {
char *arg;
static void concat(char *buf, size_t len, const char** args) {
const char *arg;
char *dest = buf;
int arg_len;
@ -27,32 +27,32 @@ static void concat(char *buf, size_t len, char** args) {
static int replace(int argc, char *argv[], char *newstr, size_t len) {
int i;
struct {
char *op;
char **res;
const char *op;
const char **res;
} ops[] = {
{ "add", (char*[]){ argv[1], " += ", argv[2], NULL } },
{ "and", (char*[]){ argv[1], " &= ", argv[2], NULL } },
{ "cls", (char*[]){ "clear_screen()", NULL } },
{ "drw", (char*[]){ "draw(", argv[1], ", ", argv[2], ", ", argv[3], ")", NULL } },
{ "exit", (char*[]){ "exit()", NULL } },
{ "high", (char*[]){ "high_res()", NULL } },
{ "jp", (char*[]){ "goto ", argv[1], NULL } },
{ "ld", (char*[]){ argv[1], " = ", argv[2], NULL } },
{ "low", (char*[]){ "low_res()", NULL } },
{ "or", (char*[]){ argv[1], " |= ", argv[2], NULL } },
{ "rnd", (char*[]){ argv[1], " = random(256) & ", argv[2], NULL } },
{ "scd", (char*[]){ "scroll_down(", argv[1], ")", NULL } },
{ "scl", (char*[]){ "scroll_left()", NULL } },
{ "scr", (char*[]){ "scroll_right()", NULL } },
{ "se", (char*[]){ "skip_next_instr if ", argv[1], " == ", argv[2], NULL } },
{ "shl", (char*[]){ argv[1], " <<= 1", NULL } },
{ "shr", (char*[]){ argv[1], " >>= 1", NULL } },
{ "sknp", (char*[]){ "skip_next_instr if !key_pressed(", argv[1], ")", NULL } },
{ "skp", (char*[]){ "skip_next_instr if key_pressed(", argv[1], ")", NULL } },
{ "sne", (char*[]){ "skip_next_instr if ", argv[1], " != ", argv[2], NULL } },
{ "sub", (char*[]){ argv[1], " -= ", argv[2], NULL } },
{ "subn", (char*[]){ argv[1], " = ", argv[2], " - ", argv[1], NULL } },
{ "xor", (char*[]){ argv[1], " ^= ", argv[2], NULL } },
{ "add", (const char*[]){ argv[1], " += ", argv[2], NULL } },
{ "and", (const char*[]){ argv[1], " &= ", argv[2], NULL } },
{ "cls", (const char*[]){ "clear_screen()", NULL } },
{ "drw", (const char*[]){ "draw(", argv[1], ", ", argv[2], ", ", argv[3], ")", NULL } },
{ "exit", (const char*[]){ "exit()", NULL } },
{ "high", (const char*[]){ "high_res()", NULL } },
{ "jp", (const char*[]){ "goto ", argv[1], NULL } },
{ "ld", (const char*[]){ argv[1], " = ", argv[2], NULL } },
{ "low", (const char*[]){ "low_res()", NULL } },
{ "or", (const char*[]){ argv[1], " |= ", argv[2], NULL } },
{ "rnd", (const char*[]){ argv[1], " = random(256) & ", argv[2], NULL } },
{ "scd", (const char*[]){ "scroll_down(", argv[1], ")", NULL } },
{ "scl", (const char*[]){ "scroll_left()", NULL } },
{ "scr", (const char*[]){ "scroll_right()", NULL } },
{ "se", (const char*[]){ "skip_next_instr if ", argv[1], " == ", argv[2], NULL } },
{ "shl", (const char*[]){ argv[1], " <<= 1", NULL } },
{ "shr", (const char*[]){ argv[1], " >>= 1", NULL } },
{ "sknp", (const char*[]){ "skip_next_instr if !key_pressed(", argv[1], ")", NULL } },
{ "skp", (const char*[]){ "skip_next_instr if key_pressed(", argv[1], ")", NULL } },
{ "sne", (const char*[]){ "skip_next_instr if ", argv[1], " != ", argv[2], NULL } },
{ "sub", (const char*[]){ argv[1], " -= ", argv[2], NULL } },
{ "subn", (const char*[]){ argv[1], " = ", argv[2], " - ", argv[1], NULL } },
{ "xor", (const char*[]){ argv[1], " ^= ", argv[2], NULL } },
{ NULL }
};

View File

@ -1,9 +1,8 @@
/* radare - LGPL - Copyright 2012-2017 - pancake */
/* radare - LGPL - Copyright 2012-2021 - pancake */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <r_lib.h>
#include <r_util.h>
#include <r_flag.h>
@ -11,10 +10,10 @@
#include <r_parse.h>
static int replace(int argc, const char *argv[], char *newstr) {
int i,j,k;
int i, j, k;
struct {
char *op;
char *str;
const char *op;
const char *str;
} ops[] = {
{ "rsub-int", "1 = 2 - 3"},
{ "float-to-double", "1 = (double)(float) 2"},

View File

@ -26,8 +26,8 @@ static bool can_replace(const char *str, int idx, int max_operands) {
static int replace(int argc, const char *argv[], char *newstr) {
int i,j,k;
struct {
char *op;
char *str;
const char *op;
const char *str;
int max_operands;
} ops[] = {
{ "move", "2 = 1", 2},

View File

@ -26,8 +26,8 @@ static int can_replace(const char *str, int idx, int max_operands) {
static int replace(int argc, const char *argv[], char *newstr) {
int i,j,k;
struct {
char *op;
char *str;
const char *op;
const char *str;
int max_operands;
} ops[] = {
{ "add", "1 = 2 + 3", 3},

View File

@ -293,8 +293,8 @@ static const char* getspr(const char *reg) {
static int replace(int argc, const char *argv[], char *newstr) {
int i,j,k;
struct {
char *op;
char *str;
const char *op;
const char *str;
int max_operands;
} ops[] = {
{ "cmpb", "A = ((byte) B == (byte) C)", 3}, //0

View File

@ -11,8 +11,8 @@ static int replace(int argc, const char *argv[], char *newstr) {
char ch;
struct {
int narg;
char *op;
char *str;
const char *op;
const char *str;
int args[MAXPSEUDOOPS];
} ops[] = {
{ 0, "add", "# = # + #", { 1, 2, 3 } },

View File

@ -13,8 +13,8 @@
static int replace(int argc, const char *argv[], char *newstr) {
int i,j,k;
struct {
char *op;
char *str;
const char *op;
const char *str;
} ops[] = {
{ "add", "B += A"},
{ "addc", "B += A + t"},

View File

@ -11,8 +11,8 @@ static int replace(int argc, const char *argv[], char *newstr) {
int i, j, k;
struct {
int narg;
char *op;
char *str;
const char *op;
const char *str;
} ops[] = {
{3, "add", "3 = 1 + 2"}, // add b12, b1, b9 -> b9 = b12 + b1
{3, "addu", "3 = 1 + 2"},

View File

@ -11,8 +11,8 @@ static int replace(int argc, const char *argv[], char *newstr) {
int i, j, k;
struct {
int narg;
char *op;
char *str;
const char *op;
const char *str;
} ops[] = {
{0, "ei", "enable-interrupts"},
{0, "di", "disable-interrupts"},

View File

@ -17,8 +17,8 @@ static int replace (int argc, char *argv[], char *newstr) {
int i, j, k, d;
char ch;
struct {
char *op;
char *str;
const char *op;
const char *str;
int args[MAXPSEUDOOPS]; // XXX can't use flex arrays, all unused will be 0
} ops[] = {
{ "adc", "# += #", {1, 2}},

View File

@ -13,8 +13,8 @@
static int replace(int argc, const char *argv[], char *newstr) {
int i,j,k;
struct {
char *op;
char *str;
const char *op;
const char *str;
} ops[] = {
{ "adc", "1 = 1 + 2"},
{ "add", "1 = 1 + 2"},

View File

@ -37,9 +37,9 @@
/* character-class table */
static struct cclass {
char *name;
char *chars;
char *multis;
const char *name;
const char *chars;
const char *multis;
} cclasses[] = {
{ "alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", ""},
{ "alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ""},

View File

@ -37,7 +37,7 @@
/* character-name table */
static struct cname {
char *name;
const char *name;
char code;
} cnames[] = {
{ "NUL", '\0' },

View File

@ -92,7 +92,7 @@ static void freeset(struct parse *, cset *);
static int freezeset(struct parse *, cset *);
static int firstch(struct parse *, cset *);
static int nch(struct parse *, cset *);
static void mcadd(struct parse *, cset *, char *);
static void mcadd(struct parse *, cset *, const char *);
static void mcinvert(struct parse *, cset *);
static void mccase(struct parse *, cset *);
static int isinsets(struct re_guts *, int);
@ -907,7 +907,7 @@ static void p_b_cclass(struct parse *p, cset *cs) {
char *sp = p->next;
struct cclass *cp;
size_t len;
char *u;
const char *u;
char c;
while (MORE () && isalpha ((unsigned char)PEEK ())) {
@ -1377,7 +1377,7 @@ static int nch(struct parse *p, cset *cs) {
/*
- mcadd - add a collating element to a cset
*/
static void mcadd( struct parse *p, cset *cs, char *cp) {
static void mcadd( struct parse *p, cset *cs, const char *cp) {
size_t oldend = cs->smultis;
void *np;

View File

@ -728,7 +728,8 @@ static RDebugPid *_extract_pid_info(const char *info, const char *path, int tid)
}
static RList *_extract_regs(char *regstr, RList *flags, char *pc_alias) {
char *regstr_end, *regname, *regtype, *tmp1, *tmpregstr, *feature_end, *typegroup;
char *regstr_end, *regname, *tmp1, *tmpregstr, *feature_end;
const char *typegroup, *regtype;
ut32 flagnum, regname_len, regsize, regnum;
RList *regs;
RListIter *iter;

View File

@ -515,9 +515,9 @@ susp_iterate_dir (struct grub_iso9660_susp_entry *entry, void *closure)
filename type is stored. */
grub_uint8_t *data = ENTRY_DATA(entry);
if (data[0] & GRUB_ISO9660_RR_DOT)
filename = ".";
filename = strdup (".");
else if (data[0] & GRUB_ISO9660_RR_DOTDOT)
filename = "..";
filename = strdup ("..");
else
{
int size = 1;

View File

@ -403,7 +403,7 @@ struct grub_xfs_iterate_dir_closure
};
static int
call_hook (grub_uint64_t ino, char *filename,
call_hook (grub_uint64_t ino, const char *filename,
struct grub_xfs_iterate_dir_closure *c)
{
struct grub_fshelp_node *fdiro;