[Libguestfs] [PATCH] rescue: fix sscanf placeholders for --smp and --memsize

Richard W.M. Jones rjones at redhat.com
Thu Aug 7 19:56:50 UTC 2014


On Thu, Aug 07, 2014 at 07:48:07PM +0200, Pino Toscano wrote:
> Use %d to parse them as int (since the variables for them as int)
> instead of %u, even if they both need to be at least > 0.
> 
> --smp was already checked to be >= 1 while --memsize not, so check that
> the specified memory size is not < 128 (which is semi-arbitrary, but
> enough as a minimum threshold).

[...]

> +      /* Check with a semi-arbitrary value, but avoids too small values
> +       * (including <= 0)
> +       */
> +      if (memsize < 128) {
> +        fprintf (stderr, _("%s: memory size %d is too small\n"),
> +                 program_name, memsize);
> +        exit (EXIT_FAILURE);
> +      }

Interestingly the library checks that memsize >= MIN_MEMSIZE, but only
when you set it through the environment variable.  I suspect the
library should check it in guestfs__set_memsize too, instead of having
to have checks scattered throughout API users.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW




More information about the Libguestfs mailing list