mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-22 02:50:08 +08:00
add casts to avoid arithmetic on void *
arithmetic on void * is undefined in ISO C, so we should avoid it. In GNU C sizeof void * is defined as 1, and that is pretty clearly what this code wants, so change it to do arithmetic on bfd_byte *. Unfortunately most of the argument types come from virtual function interfaces so changing the types to bfd_byte * isn't trivial though it might make the code clearer. So for the moment its easiest to leave the variable types as void * and cast before doing arithmetic. bfd/ChangeLog: 2016-04-26 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * elf32-rx.c (rx_set_section_contents): Avoid arithmetic on void *. * mmo.c (mmo_get_section_contents): Likewise. (mmo_set_section_contents): Likewise.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2016-04-26 Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
|
||||||
|
|
||||||
|
* elf32-rx.c (rx_set_section_contents): Avoid arithmetic on void *.
|
||||||
|
* mmo.c (mmo_get_section_contents): Likewise.
|
||||||
|
(mmo_set_section_contents): Likewise.
|
||||||
|
|
||||||
2016-04-26 H.J. Lu <hongjiu.lu@intel.com>
|
2016-04-26 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
* elf-bfd.h (elf_link_hash_table): Update comments for
|
* elf-bfd.h (elf_link_hash_table): Update comments for
|
||||||
|
@ -3548,7 +3548,7 @@ rx_set_section_contents (bfd * abfd,
|
|||||||
if (! rv)
|
if (! rv)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
location ++;
|
location = (bfd_byte *) location + 1;
|
||||||
offset ++;
|
offset ++;
|
||||||
count --;
|
count --;
|
||||||
caddr ++;
|
caddr ++;
|
||||||
@ -3574,7 +3574,7 @@ rx_set_section_contents (bfd * abfd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
count -= scount;
|
count -= scount;
|
||||||
location += scount;
|
location = (bfd_byte *) location + scount;
|
||||||
offset += scount;
|
offset += scount;
|
||||||
|
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
@ -3593,7 +3593,7 @@ rx_set_section_contents (bfd * abfd,
|
|||||||
if (! rv)
|
if (! rv)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
location ++;
|
location = (bfd_byte *) location + 1;
|
||||||
offset ++;
|
offset ++;
|
||||||
count --;
|
count --;
|
||||||
caddr ++;
|
caddr ++;
|
||||||
|
@ -2120,7 +2120,7 @@ mmo_get_section_contents (bfd *abfd ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
memcpy (location, loc, chunk_size);
|
memcpy (location, loc, chunk_size);
|
||||||
|
|
||||||
location += chunk_size;
|
location = (bfd_byte *) location + chunk_size;
|
||||||
bytes_to_do -= chunk_size;
|
bytes_to_do -= chunk_size;
|
||||||
offset += chunk_size;
|
offset += chunk_size;
|
||||||
}
|
}
|
||||||
@ -2657,7 +2657,7 @@ mmo_set_section_contents (bfd *abfd ATTRIBUTE_UNUSED, sec_ptr sec,
|
|||||||
|
|
||||||
memcpy (loc, location, chunk_size);
|
memcpy (loc, location, chunk_size);
|
||||||
|
|
||||||
location += chunk_size;
|
location = (bfd_byte *) location + chunk_size;
|
||||||
bytes_to_do -= chunk_size;
|
bytes_to_do -= chunk_size;
|
||||||
offset += chunk_size;
|
offset += chunk_size;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user