public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] bfd: Don't call bfd_write with 0 size
@ 2024-03-12 21:04 H.J. Lu
  2024-03-13 13:31 ` H.J. Lu
  0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 2024-03-12 21:04 UTC (permalink / raw)
  To: binutils; +Cc: jakub

There is no need to call bfd_write with 0 size.

	* elf-strtab.c (_bfd_elf_strtab_emit): Don't call bfd_write with
	0 size.
---
 bfd/elf-strtab.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bfd/elf-strtab.c b/bfd/elf-strtab.c
index 5fdfac12bde..b6c62f15fa0 100644
--- a/bfd/elf-strtab.c
+++ b/bfd/elf-strtab.c
@@ -326,7 +326,7 @@ _bfd_elf_strtab_emit (register bfd *abfd, struct elf_strtab_hash *tab)
 
       BFD_ASSERT (tab->array[i]->refcount == 0);
       len = tab->array[i]->len;
-      if ((int) len < 0)
+      if ((int) len <= 0)
 	continue;
 
       str = tab->array[i]->root.string;
-- 
2.44.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] bfd: Don't call bfd_write with 0 size
  2024-03-12 21:04 [PATCH] bfd: Don't call bfd_write with 0 size H.J. Lu
@ 2024-03-13 13:31 ` H.J. Lu
  0 siblings, 0 replies; 2+ messages in thread
From: H.J. Lu @ 2024-03-13 13:31 UTC (permalink / raw)
  To: binutils; +Cc: jakub

On Tue, Mar 12, 2024 at 2:04 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> There is no need to call bfd_write with 0 size.
>
>         * elf-strtab.c (_bfd_elf_strtab_emit): Don't call bfd_write with
>         0 size.
> ---
>  bfd/elf-strtab.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/bfd/elf-strtab.c b/bfd/elf-strtab.c
> index 5fdfac12bde..b6c62f15fa0 100644
> --- a/bfd/elf-strtab.c
> +++ b/bfd/elf-strtab.c
> @@ -326,7 +326,7 @@ _bfd_elf_strtab_emit (register bfd *abfd, struct elf_strtab_hash *tab)
>
>        BFD_ASSERT (tab->array[i]->refcount == 0);
>        len = tab->array[i]->len;
> -      if ((int) len < 0)
> +      if ((int) len <= 0)
>         continue;
>
>        str = tab->array[i]->root.string;
> --
> 2.44.0
>

I am checking it in.

-- 
H.J.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-13 13:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-12 21:04 [PATCH] bfd: Don't call bfd_write with 0 size H.J. Lu
2024-03-13 13:31 ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).