mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-01 00:51:19 +00:00
Small optimizations and coverity--
This commit is contained in:
parent
8e50ad6552
commit
0576be2359
@ -13,7 +13,7 @@
|
||||
|
||||
/* Returns the number that has bits+1 least significant bits set. */
|
||||
static inline ut64 genmask (int bits) {
|
||||
ut64 m = (ut64)(((2) << bits) - 1);
|
||||
ut64 m = (ut64)(((ut64)(2) << bits) - 1);
|
||||
if (!m) m = UT64_MAX;
|
||||
return m;
|
||||
}
|
||||
|
@ -1802,7 +1802,6 @@ ut64 Elf_(r_bin_elf_v2p) (struct Elf_(r_bin_elf_obj_t) *bin, ut64 vaddr) {
|
||||
if (!bin) return vaddr;
|
||||
for (i = 0; i < bin->ehdr.e_phnum; ++i) {
|
||||
Elf_(Phdr) *p = &bin->phdr[i];
|
||||
if (!p) break;
|
||||
if (p->p_type == PT_LOAD && is_in_vphdr (p, vaddr)) {
|
||||
return p->p_offset + vaddr - p->p_vaddr;
|
||||
}
|
||||
|
@ -814,16 +814,12 @@ RList* MACH0_(parse_classes)(RBinFile *arch)
|
||||
get_class_t (p, arch, processed_class);
|
||||
|
||||
if (!processed_class->name) {
|
||||
st8 *tmp = 0;
|
||||
|
||||
tmp = r_str_newf ("%s%llu", "UnnamedClass", num_of_unnamed_class);
|
||||
processed_class->name = strdup(tmp);
|
||||
processed_class->name = r_str_newf ("%s%llu", "UnnamedClass", num_of_unnamed_class);
|
||||
if (!processed_class->name) {
|
||||
goto get_classes_error;
|
||||
}
|
||||
|
||||
num_of_unnamed_class++;
|
||||
R_FREE (tmp);
|
||||
}
|
||||
|
||||
r_list_append (ret, processed_class);
|
||||
|
@ -61,6 +61,7 @@ static void * load_bytes(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr,
|
||||
dol = R_NEW0 (DolHeader);
|
||||
lowername = strdup (arch->file);
|
||||
if (sz < sizeof (DolHeader)) {
|
||||
free (lowername);
|
||||
free (dol);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
#define IS_PRINTABLE(x) (x>=' '&&x<='~')
|
||||
|
||||
/* TODO: use a whitelist :) */
|
||||
R_API int r_name_validate_char(const char ch) {
|
||||
if ((ch>='a' && ch<='z') || (ch>='A' && ch<='Z') || (ch>='0' && ch<='9'))
|
||||
return R_TRUE;
|
||||
@ -15,29 +14,11 @@ R_API int r_name_validate_char(const char ch) {
|
||||
return R_TRUE;
|
||||
}
|
||||
return R_FALSE;
|
||||
#if 0
|
||||
switch (ch) {
|
||||
case '!': case ':': case '{': case '}': case '$': case '=': case '*':
|
||||
case '/': case '+': case '|': case '&': case ';': case '~': case '"':
|
||||
case '>': case '<': case '#': case '%': case '(': case ')': case '`':
|
||||
case '\'': case '-': case ' ': case '\n': case '\t': case '[': case ']':
|
||||
case '@':
|
||||
return 0;
|
||||
default:
|
||||
if (((ch >= '0') && (ch <= '9')))
|
||||
return R_TRUE;
|
||||
if (!IS_PRINTABLE (ch))
|
||||
return R_FALSE;
|
||||
}
|
||||
return R_TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
R_API int r_name_check(const char *name) {
|
||||
if (!name || !*name)
|
||||
return R_FALSE;
|
||||
if (*name>='0' && *name<='9')
|
||||
return R_FALSE;
|
||||
for (;*name!='\0'; name++)
|
||||
if (!r_name_validate_char (*name))
|
||||
return R_FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user