util/grub-gen-asciih: fix build warning->error

Message ID 1401282382-9806-1-git-send-email-trevor.woerner@linaro.org
State New
Headers show

Commit Message

Trevor Woerner May 28, 2014, 1:06 p.m.
Using a GCC 4.8.1 cross-compiler for ARM a "may be used uninitialized in this
function" warning is generated which is converted to an error via -Werror.
This patch eliminates the warning by initializing the structure then checking
it has been filled in correctly after calling add_glyph().

Signed-off-by: Trevor Woerner <trevor.woerner@linaro.org>
---
 util/grub-gen-asciih.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Vladimir 'phcoder' Serbinenko June 21, 2014, 6:27 p.m. | #1
On 28.05.2014 15:06, Trevor Woerner wrote:
> Using a GCC 4.8.1 cross-compiler for ARM a "may be used uninitialized in this
> function" warning is generated which is converted to an error via -Werror.
> This patch eliminates the warning by initializing the structure then checking
> it has been filled in correctly after calling add_glyph().
> 
Fixed few problems and applied, thanks.
> Signed-off-by: Trevor Woerner <trevor.woerner@linaro.org>
> ---
>  util/grub-gen-asciih.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/util/grub-gen-asciih.c b/util/grub-gen-asciih.c
> index e01447a..c143afd 100644
> --- a/util/grub-gen-asciih.c
> +++ b/util/grub-gen-asciih.c
> @@ -131,6 +131,8 @@ write_font_ascii_bitmap (FILE *file, FT_Face face)
>    struct grub_glyph_info glyph;
>    int char_code;
>  
> +  memset (&glyph, 0, sizeof(glyph));
> +
>    fprintf (file, "/* THIS CHUNK OF BYTES IS AUTOMATICALLY GENERATED */\n");
>    fprintf (file, "unsigned char ascii_bitmaps[] =\n");
>    fprintf (file, "{\n");
> @@ -144,6 +146,12 @@ write_font_ascii_bitmap (FILE *file, FT_Face face)
>  	return;
>        add_glyph (glyph_idx, face, char_code, &glyph);
>  
> +      if (glyph.bitmap == 0)
> +        {
> +          fprintf (stderr, "grub-gen-asciih: add_glyph not successful");
> +          exit (1);
> +        }
> +
>        if (glyph.width == 8 && glyph.height == 16
>  	  && glyph.x_ofs == 0 && glyph.y_ofs == 0)
>  	{
>

Patch hide | download patch | download mbox

diff --git a/util/grub-gen-asciih.c b/util/grub-gen-asciih.c
index e01447a..c143afd 100644
--- a/util/grub-gen-asciih.c
+++ b/util/grub-gen-asciih.c
@@ -131,6 +131,8 @@  write_font_ascii_bitmap (FILE *file, FT_Face face)
   struct grub_glyph_info glyph;
   int char_code;
 
+  memset (&glyph, 0, sizeof(glyph));
+
   fprintf (file, "/* THIS CHUNK OF BYTES IS AUTOMATICALLY GENERATED */\n");
   fprintf (file, "unsigned char ascii_bitmaps[] =\n");
   fprintf (file, "{\n");
@@ -144,6 +146,12 @@  write_font_ascii_bitmap (FILE *file, FT_Face face)
 	return;
       add_glyph (glyph_idx, face, char_code, &glyph);
 
+      if (glyph.bitmap == 0)
+        {
+          fprintf (stderr, "grub-gen-asciih: add_glyph not successful");
+          exit (1);
+        }
+
       if (glyph.width == 8 && glyph.height == 16
 	  && glyph.x_ofs == 0 && glyph.y_ofs == 0)
 	{