diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2021-09-06 08:00:00 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2021-09-09 08:01:00 +0000 |
commit | e094270980f1ca8af86a64cee0dbb6f1df670619 (patch) | |
tree | 1471f9586bb9e3d7f5448001353d47e94145a4ae /libdw | |
parent | 02b05e183998943dd5a19ba783b8793e2ab9ab44 (diff) | |
download | elfutils-e094270980f1ca8af86a64cee0dbb6f1df670619.tar.gz |
Remove redundant casts of memory allocating functions returning void *
Return values of functions returning "void *", e.g. calloc, malloc,
realloc, xcalloc, xmalloc, and xrealloc, do not need explicit casts.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Diffstat (limited to 'libdw')
-rw-r--r-- | libdw/ChangeLog | 9 | ||||
-rw-r--r-- | libdw/dwarf_begin_elf.c | 8 | ||||
-rw-r--r-- | libdw/dwarf_getpubnames.c | 5 | ||||
-rw-r--r-- | libdw/dwarf_getsrclines.c | 2 |
4 files changed, 16 insertions, 8 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog index b5462ef4..768d5c25 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,12 @@ +2021-09-06 Dmitry V. Levin <ldv@altlinux.org> + + * dwarf_begin_elf.c (valid_p): Remove casts of malloc return values. + (dwarf_begin_elf): Remove cast of calloc return value. + * dwarf_getpubnames.c (get_offsets): Remove casts of realloc return + values. + * dwarf_getsrclines.c (read_srclines): Remove cast of malloc return + value. + 2021-04-19 Martin Liska <mliska@suse.cz> * dwarf_begin_elf.c (check_section): Use startswith. diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c index 9e944b86..7bde61b3 100644 --- a/libdw/dwarf_begin_elf.c +++ b/libdw/dwarf_begin_elf.c @@ -229,7 +229,7 @@ valid_p (Dwarf *result) inside the .debug_loc or .debug_loclists section. */ if (result != NULL && result->sectiondata[IDX_debug_loc] != NULL) { - result->fake_loc_cu = (Dwarf_CU *) malloc (sizeof (Dwarf_CU)); + result->fake_loc_cu = malloc (sizeof (Dwarf_CU)); if (unlikely (result->fake_loc_cu == NULL)) { Dwarf_Sig8_Hash_free (&result->sig8_hash); @@ -255,7 +255,7 @@ valid_p (Dwarf *result) if (result != NULL && result->sectiondata[IDX_debug_loclists] != NULL) { - result->fake_loclists_cu = (Dwarf_CU *) malloc (sizeof (Dwarf_CU)); + result->fake_loclists_cu = malloc (sizeof (Dwarf_CU)); if (unlikely (result->fake_loclists_cu == NULL)) { Dwarf_Sig8_Hash_free (&result->sig8_hash); @@ -286,7 +286,7 @@ valid_p (Dwarf *result) inside the .debug_addr section, if it exists. */ if (result != NULL && result->sectiondata[IDX_debug_addr] != NULL) { - result->fake_addr_cu = (Dwarf_CU *) malloc (sizeof (Dwarf_CU)); + result->fake_addr_cu = malloc (sizeof (Dwarf_CU)); if (unlikely (result->fake_addr_cu == NULL)) { Dwarf_Sig8_Hash_free (&result->sig8_hash); @@ -415,7 +415,7 @@ dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp) assert (sizeof (struct Dwarf) < mem_default_size); /* Allocate the data structure. */ - Dwarf *result = (Dwarf *) calloc (1, sizeof (Dwarf)); + Dwarf *result = calloc (1, sizeof (Dwarf)); if (unlikely (result == NULL) || unlikely (Dwarf_Sig8_Hash_init (&result->sig8_hash, 11) < 0)) { diff --git a/libdw/dwarf_getpubnames.c b/libdw/dwarf_getpubnames.c index 25600f33..de726407 100644 --- a/libdw/dwarf_getpubnames.c +++ b/libdw/dwarf_getpubnames.c @@ -57,8 +57,7 @@ get_offsets (Dwarf *dbg) if (cnt >= allocated) { allocated = MAX (10, 2 * allocated); - struct pubnames_s *newmem - = (struct pubnames_s *) realloc (mem, allocated * entsize); + struct pubnames_s *newmem = realloc (mem, allocated * entsize); if (newmem == NULL) { __libdw_seterrno (DWARF_E_NOMEM); @@ -132,7 +131,7 @@ get_offsets (Dwarf *dbg) return -1; } - dbg->pubnames_sets = (struct pubnames_s *) realloc (mem, cnt * entsize); + dbg->pubnames_sets = realloc (mem, cnt * entsize); dbg->pubnames_nsets = cnt; return 0; diff --git a/libdw/dwarf_getsrclines.c b/libdw/dwarf_getsrclines.c index d6a581ad..8fc48e1d 100644 --- a/libdw/dwarf_getsrclines.c +++ b/libdw/dwarf_getsrclines.c @@ -372,7 +372,7 @@ read_srclines (Dwarf *dbg, { if (ndirlist > SIZE_MAX / sizeof (*dirarray)) goto no_mem; - dirarray = (struct dirlist *) malloc (ndirlist * sizeof (*dirarray)); + dirarray = malloc (ndirlist * sizeof (*dirarray)); if (unlikely (dirarray == NULL)) { no_mem: |