Re: More format string fixups (was: Re: [PATCH] Persuade yadex to work on amd64)

  • From: Andre Majorel <amajorel@xxxxxxxxx>
  • To: yadex@xxxxxxxxxxxxx
  • Date: Sun, 2 Jul 2006 14:58:04 +0200

Sorry for the lack of response, I've been busy.

On 2006-06-19 01:22 +0100, Darren Salt wrote:

> diff -urNad yadex-1.7.900~/GNUmakefile yadex-1.7.900/GNUmakefile
> --- yadex-1.7.900~/scripts/m7.cc      2006-06-19 00:53:02.000000000 +0100
> +++ yadex-1.7.900/scripts/m7.cc       2006-06-19 00:53:03.087795500 +0100
> @@ -951,7 +951,7 @@
>      }
>      if (r != 0)
>      {
> -      err ("M7270", "%s: an error occurred in argument %d of macro \"%s\"",
> +      err ("M7270", "%s: an error occurred in argument %lu of macro \"%s\"",
>         input.where (), args.size () + 1, token);

Added the missing cast and applied.

> diff -urNad yadex-1.7.900~/src/acolours.cc yadex-1.7.900/src/acolours.cc
> --- yadex-1.7.900~/src/acolours.cc    2006-06-19 00:53:01.000000000 +0100
> +++ yadex-1.7.900/src/acolours.cc     2006-06-19 00:53:03.091795750 +0100
> @@ -113,7 +113,6 @@
>  
>    /* First create an array of RGB values
>       for all the colours in the list. */
> -  verbmsg ("colours: rgb_values %p\n");

Ouch ! Applied.

> --- yadex-1.7.900~/src/colour4.cc     2006-06-19 00:53:01.000000000 +0100
> +++ yadex-1.7.900/src/colour4.cc      2006-06-19 00:53:03.091795750 +0100
> @@ -72,7 +72,7 @@
>   */
>  pcolour_t *alloc_colours (rgb_c rgb_values[], size_t count)
>  {
> -  verbmsg ("colours: alloc_colours: count %d\n", count);
> +  verbmsg ("colours: alloc_colours: count %zu\n", count);
> -  verbmsg ("colours: free_colours: count %d\n", count);
> +  verbmsg ("colours: free_colours: count %zu\n", count);
> -  verbmsg ("colours: freed %d of %d physical colours\n",
> +  verbmsg ("colours: freed %ld of %zu physical colours\n",

Added the missing cast and applied.

> --- yadex-1.7.900~/src/editloop.cc    2006-06-19 00:53:01.000000000 +0100
> +++ yadex-1.7.900/src/editloop.cc     2006-06-19 00:53:03.091795750 +0100
> @@ -1196,9 +1196,9 @@
>        strcpy (buf2, "buf2");
>        strcpy (buf3, "buf3");
>        Entry2 e ("Title of window", "Buf 1%*sBuf 2%*sBuf 3%*s",
> -          sizeof buf1 - 1, buf1,
> -          sizeof buf2 - 1, buf2,
> -          sizeof buf3 - 1, buf3);
> +          (int) sizeof buf1 - 1, buf1,
> +          (int) sizeof buf2 - 1, buf2,
> +          (int) sizeof buf3 - 1, buf3);

Applied.

> --- yadex-1.7.900~/src/game.cc        2006-06-19 00:53:01.000000000 +0100
> +++ yadex-1.7.900/src/game.cc 2006-06-19 00:53:03.095796000 +0100
> @@ -88,7 +88,7 @@
>    if (pathname == NULL)
>      fatal_error ("Game definition file \"%s\" not found", basename);
>    if (strlen (pathname) > sizeof filename - 1)
> -    fatal_error ("%s: file name too long");
> +    fatal_error ("%s: file name too long", pathname);

Re-ouch. Applied.

> -            fatal_error ("%s(%d): more than %d tokens",
> +            fatal_error ("%s(%d): more than %lu tokens",

AMCAA.

>        fatal_error (
> -            "%s(d%): directive \"%s\" takes between 5 and 6 parameters",
> +            "%s(%d): directive \"%s\" takes between 5 and 6 parameters",

Ha ! This software has been tested. Tes-ted, I'm telling you.

> +++ yadex-1.7.900/src/gfx.cc  2006-06-19 00:53:03.095796000 +0100
> @@ -302,7 +302,7 @@
>      model.visualid = XVisualIDFromVisual (win_vis);
>      vis_info = XGetVisualInfo (dpy, VisualIDMask, &model, &nvisuals);
>      if (! vis_info)
> -      fatal_error ("XGetVisualInfo returned NULL for ID %d", model.visualid);
> +      fatal_error ("XGetVisualInfo returned NULL for ID %ld", (long) 
> model.visualid);

AMCAA.

> --- yadex-1.7.900~/src/help2.cc       2006-06-19 00:53:01.000000000 +0100
> +++ yadex-1.7.900/src/help2.cc        2006-06-19 00:53:03.095796000 +0100
> @@ -106,9 +106,9 @@
>                 y0 + BOX_BORDER + FONTH / 2,
>                 "Yadex");
>    set_colour (WINFG);
> -  DrawScreenText (x0 + BOX_BORDER + 2 * FONTW, y0 + BOX_BORDER + FONTH, "");
> +  DrawScreenString (x0 + BOX_BORDER + 2 * FONTW, y0 + BOX_BORDER + FONTH, 
> "");
>    for (const char **str = help_text; *str; str++)
> -     DrawScreenText (-1, -1, *str);
> +     DrawScreenString (-1, -1, *str);

Not a good idea.

> --- yadex-1.7.900~/src/levels.cc      2006-06-19 00:53:01.000000000 +0100
> +++ yadex-1.7.900/src/levels.cc       2006-06-19 00:53:03.095796000 +0100
> @@ -487,7 +487,7 @@
>           wf->read_i32 (offset_table + n);
>           if (wf->error ())
>              {
> -            warn ("%s: error reading offsets table\n");
> +            warn ("%s: error reading offsets table\n", lump_name);

Applied.

> -      warn ("%s: seek error\n", wad_level_lump[l]);
> +      warn ("%s: seek error\n", wad_level_lump[l].name);
> -      warn ("%s: seek error\n", wad_level_lump[l]);
> +      warn ("%s: seek error\n", wad_level_lump[l].name);
> -      warn ("%s: seek error\n", wad_level_lump[l]);
> +      warn ("%s: seek error\n", wad_level_lump[l].name);
> -      warn ("%s: seek error\n", wad_level_lump[l]);
> +      warn ("%s: seek error\n", wad_level_lump[l].name);

What was I thinking ? Applied.

> --- yadex-1.7.900~/src/memory.cc      2006-06-19 00:53:01.000000000 +0100
> +++ yadex-1.7.900/src/memory.cc       2006-06-19 00:53:03.095796000 +0100
> @@ -72,7 +72,7 @@
>     ret = malloc ((size_t) size);
>     }
>  if (!ret)
> -   fatal_error ("out of memory (cannot allocate %u bytes)", size);
> +   fatal_error ("out of memory (cannot allocate %lu bytes)", size);

Applied.

> --- yadex-1.7.900~/src/patchdir.cc    2006-06-19 00:53:01.000000000 +0100
> +++ yadex-1.7.900/src/patchdir.cc     2006-06-19 00:53:03.099796250 +0100
> @@ -107,8 +107,8 @@
>        }
>        if (pnames_body_size % 8)
>        {
> -     warn ("%s lump has weird size %ld, discarding last %d bytes\n",
> -         (long) dir->dir.size, (int) (pnames_body_size % 8));
> +     warn ("%s: lump has weird size %ld, discarding last %d bytes\n",
> +         lump_name, (long) dir->dir.size, (int) (pnames_body_size % 8));

OMG. Applied.

> diff -urNad yadex-1.7.900~/src/wads2.cc yadex-1.7.900/src/wads2.cc
> --- yadex-1.7.900~/src/wads2.cc       2006-06-19 00:53:02.000000000 +0100
> +++ yadex-1.7.900/src/wads2.cc        2006-06-19 00:53:03.099796250 +0100
> @@ -244,14 +244,14 @@
>        if (names >= 6)
>           {
>        verbmsg ("\n  %-*s %-*s",
> -          strlen (replaces ? "Updating" : "Adding new"), "",
> -          strlen (entry_type), "");
> +          (int) strlen (replaces ? "Updating" : "Adding new"), "",
> +          (int) strlen (entry_type), "");

Applied.

> -   else                                      fatal_error ("Wrong acn %d", n);
> +   else                                      fatal_error ("Wrong acn %zu", 
> n);
> -      fatal_error ("add_base_colours: got %d for %d\n", acn, n);
> +      fatal_error ("add_base_colours: got %d for %zu\n", acn, n);
> -      verbmsg (" warning: non-zero length (%ld)", wad->directory[n].size);
> +      verbmsg (" warning: non-zero length (%"PRId32")", 
> wad->directory[n].size);

Cast instead !

Thanks.

-- 
André Majorel <amajorel@xxxxxxxxx>
http://www.teaser.fr/~amajorel/

Other related posts: