asprintf and snprintf support
This commit is contained in:
parent
c181849b95
commit
8b442f3f4c
60 changed files with 396 additions and 345 deletions
|
@ -1138,14 +1138,20 @@ grub_cmd_freebsd_loadenv (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
if (*curr)
|
||||
{
|
||||
char name[grub_strlen (curr) + sizeof("kFreeBSD.")];
|
||||
char *name;
|
||||
|
||||
if (*p == '"')
|
||||
p++;
|
||||
|
||||
grub_sprintf (name, "kFreeBSD.%s", curr);
|
||||
if (grub_env_set (name, p))
|
||||
name = grub_asprintf ("kFreeBSD.%s", curr);
|
||||
if (!name)
|
||||
goto fail;
|
||||
if (grub_env_set (name, p))
|
||||
{
|
||||
grub_free (name);
|
||||
goto fail;
|
||||
}
|
||||
grub_free (name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -517,11 +517,9 @@ grub_linux_boot (void)
|
|||
May change in future if we have modes without framebuffer. */
|
||||
if (modevar && *modevar != 0)
|
||||
{
|
||||
tmp = grub_malloc (grub_strlen (modevar)
|
||||
+ sizeof (";text"));
|
||||
tmp = grub_asprintf ("%s;text", modevar);
|
||||
if (! tmp)
|
||||
return grub_errno;
|
||||
grub_sprintf (tmp, "%s;text", modevar);
|
||||
err = grub_video_set_mode (tmp, 0);
|
||||
grub_free (tmp);
|
||||
}
|
||||
|
@ -779,19 +777,18 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
break;
|
||||
}
|
||||
|
||||
buf = grub_malloc (sizeof ("WWWWxHHHHxDD;WWWWxHHHH"));
|
||||
if (! buf)
|
||||
goto fail;
|
||||
|
||||
linux_mode
|
||||
= &linux_vesafb_modes[vid_mode - GRUB_LINUX_VID_MODE_VESA_START];
|
||||
|
||||
grub_sprintf (buf, "%ux%ux%u,%ux%u",
|
||||
linux_vesafb_res[linux_mode->res_index].width,
|
||||
linux_vesafb_res[linux_mode->res_index].height,
|
||||
linux_mode->depth,
|
||||
linux_vesafb_res[linux_mode->res_index].width,
|
||||
linux_vesafb_res[linux_mode->res_index].height);
|
||||
buf = grub_asprintf ("%ux%ux%u,%ux%u",
|
||||
linux_vesafb_res[linux_mode->res_index].width,
|
||||
linux_vesafb_res[linux_mode->res_index].height,
|
||||
linux_mode->depth,
|
||||
linux_vesafb_res[linux_mode->res_index].width,
|
||||
linux_vesafb_res[linux_mode->res_index].height);
|
||||
if (! buf)
|
||||
goto fail;
|
||||
|
||||
grub_printf ("%s is deprecated. "
|
||||
"Use set gfxpayload=%s before "
|
||||
"linux command instead.\n",
|
||||
|
|
|
@ -52,12 +52,10 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params)
|
|||
err = grub_video_set_mode (DEFAULT_VIDEO_MODE, video_hook);
|
||||
else
|
||||
{
|
||||
tmp = grub_malloc (grub_strlen (modevar)
|
||||
+ sizeof (DEFAULT_VIDEO_MODE) + 1);
|
||||
tmp = grub_asprintf ("%s;" DEFAULT_VIDEO_MODE, modevar);
|
||||
if (! tmp)
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"couldn't allocate temporary storag");
|
||||
grub_sprintf (tmp, "%s;" DEFAULT_VIDEO_MODE, modevar);
|
||||
err = grub_video_set_mode (tmp, video_hook);
|
||||
grub_free (tmp);
|
||||
}
|
||||
|
|
|
@ -748,11 +748,13 @@ grub_cpu_xnu_fill_devicetree (void)
|
|||
#endif
|
||||
|
||||
/* The name of key for new table. */
|
||||
grub_sprintf (guidbuf, "%08x-%04x-%04x-%02x%02x-",
|
||||
guid.data1, guid.data2, guid.data3, guid.data4[0],
|
||||
guid.data4[1]);
|
||||
grub_snprintf (guidbuf, sizeof (guidbuf), "%08x-%04x-%04x-%02x%02x-",
|
||||
guid.data1, guid.data2, guid.data3, guid.data4[0],
|
||||
guid.data4[1]);
|
||||
for (j = 2; j < 8; j++)
|
||||
grub_sprintf (guidbuf + grub_strlen (guidbuf), "%02x", guid.data4[j]);
|
||||
grub_snprintf (guidbuf + grub_strlen (guidbuf),
|
||||
sizeof (guidbuf) - grub_strlen (guidbuf),
|
||||
"%02x", guid.data4[j]);
|
||||
/* For some reason GUID has to be in uppercase. */
|
||||
for (j = 0; guidbuf[j] ; j++)
|
||||
if (guidbuf[j] >= 'a' && guidbuf[j] <= 'f')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue