bfd/pdb: fix -Wmaybe-uninitialized warning

Message ID 20240904175331.27242-1-mark@harmstone.com
State New
Headers
Series bfd/pdb: fix -Wmaybe-uninitialized warning |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Mark Harmstone Sept. 4, 2024, 5:53 p.m. UTC
  Initialize stream0_start to fix spurious -Wmaybe-uninitialized warning
on some versions of gcc.
---
 bfd/pdb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Alan Modra Sept. 5, 2024, 6:52 a.m. UTC | #1
On Wed, Sep 04, 2024 at 06:53:25PM +0100, Mark Harmstone wrote:
> Initialize stream0_start to fix spurious -Wmaybe-uninitialized warning
> on some versions of gcc.

Please apply.  This sort of fix to a patch is fine to apply as abvious.

> ---
>  bfd/pdb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/bfd/pdb.c b/bfd/pdb.c
> index c4c528711ed..340cda667a2 100644
> --- a/bfd/pdb.c
> +++ b/bfd/pdb.c
> @@ -718,7 +718,7 @@ pdb_write_contents (bfd *abfd)
>    uint32_t num_blocks;
>    uint32_t num_files = 0;
>    uint32_t num_directory_bytes = sizeof (uint32_t);
> -  uint32_t stream0_start;
> +  uint32_t stream0_start = 0;
>    bfd *arelt;
>  
>    if (bfd_write (pdb_magic, sizeof (pdb_magic), abfd) != sizeof (pdb_magic))
> -- 
> 2.44.2
  

Patch

diff --git a/bfd/pdb.c b/bfd/pdb.c
index c4c528711ed..340cda667a2 100644
--- a/bfd/pdb.c
+++ b/bfd/pdb.c
@@ -718,7 +718,7 @@  pdb_write_contents (bfd *abfd)
   uint32_t num_blocks;
   uint32_t num_files = 0;
   uint32_t num_directory_bytes = sizeof (uint32_t);
-  uint32_t stream0_start;
+  uint32_t stream0_start = 0;
   bfd *arelt;
 
   if (bfd_write (pdb_magic, sizeof (pdb_magic), abfd) != sizeof (pdb_magic))