search for: longint_ok

Displaying 20 results from an estimated 52 matches for "longint_ok".

2015 Oct 22
1
[PATCH] Bugfix in number parsing in vfs_min_size.
...7..6543574 100644 --- a/daemon/ext2.c +++ b/daemon/ext2.c @@ -336,7 +336,7 @@ ext_minimum_size (const char *device) for (i = 0; lines[i] != NULL; ++i) { if (STRPREFIX (lines[i], pattern)) { if (XSTRTOD64 (lines[i] + strlen (pattern), - NULL, 20, &ret, NULL) != LONGINT_OK) { + NULL, 10, &ret, NULL) != LONGINT_OK) { reply_with_error ("cannot parse minimum size"); return -1; } diff --git a/daemon/ntfs.c b/daemon/ntfs.c index ea0844f..8e1aa5a 100644 --- a/daemon/ntfs.c +++ b/daemon/ntfs.c @@ -201,7 +201,7 @@ nt...
2016 Jul 18
2
[PATCH] mllib: Getopt: fix integer parsing
...xstrtol.h" + #include <caml/alloc.h> #include <caml/fail.h> #include <caml/memory.h> @@ -117,6 +119,26 @@ do_call1 (value funv, value paramv) CAMLreturn0; } +static int +strtoint (const char *arg) +{ + long int num; + + if (xstrtol (arg, NULL, 0, &num, NULL) != LONGINT_OK) { + fprintf (stderr, _("%s: '%s' is not a numeric value.\n"), + guestfs_int_program_name, arg); + show_error (EXIT_FAILURE); + } + + if (num <= INT_MIN || num >= INT_MAX) { + fprintf (stderr, _("%s: %s: integer out of range\n"), +...
2016 Jul 18
0
[PATCH v3 1/3] mllib: getopt: Further fix int parsing.
...++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mllib/getopt-c.c b/mllib/getopt-c.c index bf40f91..13852c2 100644 --- a/mllib/getopt-c.c +++ b/mllib/getopt-c.c @@ -124,13 +124,13 @@ strtoint (const char *arg) { long int num; - if (xstrtol (arg, NULL, 0, &num, NULL) != LONGINT_OK) { + if (xstrtol (arg, NULL, 0, &num, "") != LONGINT_OK) { fprintf (stderr, _("%s: '%s' is not a numeric value.\n"), guestfs_int_program_name, arg); show_error (EXIT_FAILURE); } - if (num <= -(2LL<<30) || num >= ((2LL<&lt...
2015 Oct 20
4
[PATCHv3 0/2] Introduce vfs_min_size API to get minimum filesystem size.
Tried to make it in accordance with your comments. Difference to v1: Added reply_with_error where necessary. Changed name get_min_size -> vfs_min_size. Difference to v2: Changed name to vfs_minimum_size. Changed parsing to xstrtol + STR* macros where possible. Maxim Perevedentsev (2): New API: vfs_min_size Include resize2fs_P into vfs_min_size. daemon/Makefile.am | 1 +
2015 Oct 20
0
[PATCHv3 2/2] Include resize2fs_P into vfs_min_size.
...rn = "Block size"; + size_t i; + long block_size; + + params = do_tune2fs_l (device); + if (params == NULL) + return -1; + + for (i = 0; params[i] != NULL; i += 2) { + if (STREQ (params[i], block_pattern)) { + if (xstrtol (params[i + 1], NULL, 10, &block_size, NULL) != LONGINT_OK) { + reply_with_error ("Cannot parse block size"); + return -1; + } + return block_size; + } + } + + reply_with_error ("Missing 'Block size' in tune2fs_l output"); + return -1; +} + int64_t -do_resize2fs_P (const char *device) +ext_minimum_...
2014 Dec 05
2
Re: [PATCH 1/8] New API: btrfs_subvolume_get_default
...39;s "xstrtol" function is a minefield, and the code above won't work [specifically -- it's insecure] on 32 bit machines. Anyway, I think it's better to use sscanf here, so: if (sscanf (out, "ID %" SCNi64, &ret) != 2) { // error ... } > + if (r != LONGINT_OK) { > + reply_with_error ("%s: could not parse subvolume id: %s.", argv[0], out); > + return -1; > + } > + > + return ret; > +} > + > int > do_btrfs_filesystem_sync (const char *fs) > { > diff --git a/generator/actions.ml b/generator/actions.ml &...
2015 Oct 20
8
[PATCHv4 0/2] Introduce vfs_minimum_size API to get minimum filesystem size.
Tried to make it in accordance with your comments. Difference to v1: Added reply_with_error where necessary. Changed name get_min_size -> vfs_min_size. Difference to v2: Changed name to vfs_minimum_size. Changed parsing to xstrtol + STR* macros where possible. Difference to v3: Decapitalize error messages. Maxim Perevedentsev (2): New API: vfs_minimum_size Include resize2fs_P into
2013 Jan 24
5
[PATCH] btrfs: Fix btrfs_subvolume_list on F18
The output of btrfs subvolume list has changed in F18 to include generation, which breaks the parsing in btrfs_subvolume_list. This change replaces sscanf with a more robust regular expression. The new regular expression should also handle the addition of future unexpected columns. Fixes RHBZ#903620 --- daemon/Makefile.am | 6 +++-- daemon/btrfs.c | 67
2014 Sep 04
10
[PATCH 0/5] use augeas for /etc/shadow
Hi, currently /etc/shadow is edited manually when needed (i.e. when setting the password for an user), and it is not changed when removing users. Import the upstream shadow.aug (currently in their development serie, but not part of any released version yet), and use it only when the augeas version is less than a potential 1.2.1 (covering also the case when the new version is just 1.3.0). Pino
2015 Oct 20
0
[PATCHv3 1/2] New API: vfs_min_size
...{ + reply_with_error ("Cannot parse cluster size"); + return -1; + } + } + else if (STRPREFIX (lines[i], volume_size_pattern)) { + if (XSTRTOD64 (lines[i] + strlen (volume_size_pattern), + NULL, 20, &volume_size, NULL) != LONGINT_OK) { + reply_with_error ("Cannot parse volume size"); + return -1; + } + } + } + if (is_full) { + if (cluster_size == 0) { + reply_with_error ("Bad cluster size"); + return -1; + } + /* In case of a full filesystem,...
2015 Oct 20
0
[PATCHv4 1/2] New API: vfs_minimum_size
...{ + reply_with_error ("cannot parse cluster size"); + return -1; + } + } + else if (STRPREFIX (lines[i], volume_size_pattern)) { + if (XSTRTOD64 (lines[i] + strlen (volume_size_pattern), + NULL, 20, &volume_size, NULL) != LONGINT_OK) { + reply_with_error ("cannot parse volume size"); + return -1; + } + } + } + if (is_full) { + if (cluster_size == 0) { + reply_with_error ("bad cluster size"); + return -1; + } + /* In case of a full filesystem,...
2015 Oct 27
1
[PATCHv3] Added btrfs support to vfs_minimum_size.
..."min-dev-size", sysroot_path (path), NULL); + + if (r == -1) { + reply_with_error ("%s", err); + return -1; + } + +#if __WORDSIZE == 64 +#define XSTRTOD64 xstrtol +#else +#define XSTRTOD64 xstrtoll +#endif + + if (XSTRTOD64 (out, NULL, 10, &ret, NULL) != LONGINT_OK) { + reply_with_error ("cannot parse minimum size"); + return -1; + } + +#undef XSTRTOD64 + + return ret; +} diff --git a/daemon/daemon.h b/daemon/daemon.h index 8bcc9bd..4a969dd 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -280,6 +280,7 @@ extern char *btrfs_get_label (c...
2017 Jul 21
0
[PATCH v2 15/23] daemon: Reimplement ‘btrfs_subvolume_list’ and ‘btrfs_subvolume_get_default’ in OCaml.
...tfs_int_btrfssubvolume *this = - &ret->guestfs_int_btrfssubvolume_list_val[i]; - -#if __WORDSIZE == 64 -#define XSTRTOU64 xstrtoul -#else -#define XSTRTOU64 xstrtoull -#endif - - if (XSTRTOU64 (line + ovector[2], NULL, 10, - &this->btrfssubvolume_id, NULL) != LONGINT_OK) - goto unexpected_output; - if (XSTRTOU64 (line + ovector[4], NULL, 10, - &this->btrfssubvolume_top_level_id, NULL) != LONGINT_OK) - goto unexpected_output; - -#undef XSTRTOU64 - - this->btrfssubvolume_path = - strndup (line + ovector[6], ovector[7]...
2015 Oct 22
2
[PATCH] Added btrfs support for vfs_min_size.
...quot;, + "min-dev-size", path, NULL); + + if (r == -1) { + reply_with_error ("%s", err); + return -1; + } + +#if __WORDSIZE == 64 +#define XSTRTOD64 xstrtol +#else +#define XSTRTOD64 xstrtoll +#endif + + if (XSTRTOD64 (out, NULL, 10, &ret, NULL) != LONGINT_OK) { + reply_with_error ("cannot parse minimum size"); + return -1; + } + +#undef XSTRTOD64 + + return ret; +} + diff --git a/daemon/daemon.h b/daemon/daemon.h index 8bcc9bd..4a969dd 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -280,6 +280,7 @@ extern char *btrfs_get_label...
2017 Jul 14
0
[PATCH 18/27] daemon: Reimplement ‘btrfs_subvolume_list’ and ‘btrfs_subvolume_get_default’ in OCaml.
...tfs_int_btrfssubvolume *this = - &ret->guestfs_int_btrfssubvolume_list_val[i]; - -#if __WORDSIZE == 64 -#define XSTRTOU64 xstrtoul -#else -#define XSTRTOU64 xstrtoull -#endif - - if (XSTRTOU64 (line + ovector[2], NULL, 10, - &this->btrfssubvolume_id, NULL) != LONGINT_OK) - goto unexpected_output; - if (XSTRTOU64 (line + ovector[4], NULL, 10, - &this->btrfssubvolume_top_level_id, NULL) != LONGINT_OK) - goto unexpected_output; - -#undef XSTRTOU64 - - this->btrfssubvolume_path = - strndup (line + ovector[6], ovector[7]...
2014 Dec 02
0
[PATCH 1/8] New API: btrfs_subvolume_get_default
...v, i, "get-default"); + ADD_ARG (argv, i, fs_buf); + ADD_ARG (argv, i, NULL); + + r = commandv (&out, &err, argv); + if (r == -1) { + reply_with_error ("%s: %s", mountpoint, err); + return -1; + } + r = xstrtol (out + 2, NULL, 10, &ret, NULL); + if (r != LONGINT_OK) { + reply_with_error ("%s: could not parse subvolume id: %s.", argv[0], out); + return -1; + } + + return ret; +} + int do_btrfs_filesystem_sync (const char *fs) { diff --git a/generator/actions.ml b/generator/actions.ml index 385b620..80c7ea7 100644 --- a/generator/actions.ml...
2016 Jul 18
0
Re: [PATCH] mllib: Getopt: fix integer parsing
...tion) are signed 63 bits. I think returning 'long' is a better idea, and the receiving 'num' should also be 'long' (as in my patch). > +static int > +strtoint (const char *arg) > +{ > + long int num; > + > + if (xstrtol (arg, NULL, 0, &num, NULL) != LONGINT_OK) { > + fprintf (stderr, _("%s: '%s' is not a numeric value.\n"), > + guestfs_int_program_name, arg); > + show_error (EXIT_FAILURE); > + } > + > + if (num <= INT_MIN || num >= INT_MAX) { > + fprintf (stderr, _("%s: %s: integer...
2015 Jul 02
0
[PATCH] Fix various -Wformat problems.
...f"); exit (EXIT_FAILURE); } diff --git a/fish/alloc.c b/fish/alloc.c index b40284a..9f41915 100644 --- a/fish/alloc.c +++ b/fish/alloc.c @@ -97,7 +97,7 @@ parse_size (const char *str, off_t *size_rtn) xerr = xstrtoull (str, NULL, 0, &size, "0kKMGTPEZY"); if (xerr != LONGINT_OK) { fprintf (stderr, - _("%s: invalid integer parameter (%s returned %d)\n"), + _("%s: invalid integer parameter (%s returned %u)\n"), "parse_size", "xstrtoull", xerr); return -1; } diff --git a/fish/rc.c b/fi...
2015 Jul 02
0
[PATCH v2] Fix various -Wformat problems.
...f"); exit (EXIT_FAILURE); } diff --git a/fish/alloc.c b/fish/alloc.c index b40284a..9f41915 100644 --- a/fish/alloc.c +++ b/fish/alloc.c @@ -97,7 +97,7 @@ parse_size (const char *str, off_t *size_rtn) xerr = xstrtoull (str, NULL, 0, &size, "0kKMGTPEZY"); if (xerr != LONGINT_OK) { fprintf (stderr, - _("%s: invalid integer parameter (%s returned %d)\n"), + _("%s: invalid integer parameter (%s returned %u)\n"), "parse_size", "xstrtoull", xerr); return -1; } diff --git a/fish/rc.c b/fi...
2016 Jul 18
2
Re: [PATCH] mllib: Getopt: fix integer parsing
...bit vs 64bit builds. If we really 64bit values as parameters, then let's just create a new option type marking that. > > > +static int > > +strtoint (const char *arg) > > +{ > > + long int num; > > + > > + if (xstrtol (arg, NULL, 0, &num, NULL) != LONGINT_OK) { > > + fprintf (stderr, _("%s: '%s' is not a numeric value.\n"), > > + guestfs_int_program_name, arg); > > + show_error (EXIT_FAILURE); > > + } > > + > > + if (num <= INT_MIN || num >= INT_MAX) { > > + fprint...