Reduce stack move path local to heap

To use the -fstack-check gcc option each stack frame must be
keep reasonably small.  In this case the path local is moved
from the stack to the heap to keep us under the limit.

  warning: frame size too large for reliable stack checking
  warning: try reducing the number of local variables
This commit is contained in:
Brian Behlendorf 2010-07-22 13:16:33 -07:00
parent 064837c20a
commit c0932825ea
1 changed files with 11 additions and 3 deletions

View File

@ -149,10 +149,16 @@ static int
efi_get_info(int fd, struct dk_cinfo *dki_info)
{
#if defined(__linux__)
char path[PATH_MAX];
char *path;
char *dev_path;
int rval = 0;
memset(dki_info, 0, sizeof(*dki_info));
path = calloc(PATH_MAX, 1);
if (path == NULL)
goto error;
/*
* The simplest way to get the partition number under linux is
* to parse it out of the /dev/<disk><parition> block device name.
@ -166,9 +172,11 @@ efi_get_info(int fd, struct dk_cinfo *dki_info)
* /proc/self/fd/<fd>. Aside from the partition number we collect
* some additional device info.
*/
memset(dki_info, 0, sizeof(*dki_info));
(void) sprintf(path, "/proc/self/fd/%d", fd);
if ((dev_path = realpath(path, NULL)) == NULL)
dev_path = realpath(path, NULL);
free(path);
if (dev_path == NULL)
goto error;
if ((strncmp(dev_path, "/dev/sd", 7) == 0)) {