aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil/strtoi.c
AgeCommit message (Collapse)AuthorFilesLines
2016-11-03wsutil: add initializer (found by clang ccc).Dario Lombardo1-1/+1
Warning: wireshark/wsutil/strtoi.c:113:1: warning: The left operand of '<' is a garbage value DEFINE_WS_STRTOI_BITS(32) ^~~~~~~~~~~~~~~~~~~~~~~~~ wireshark/wsutil/strtoi.c:83:12: note: expanded from macro 'DEFINE_WS_STRTOI_BITS' if (val < 0) \ ~~~ ^ wireshark/wsutil/strtoi.c:114:1: warning: The left operand of '<' is a garbage value DEFINE_WS_STRTOI_BITS(16) ^~~~~~~~~~~~~~~~~~~~~~~~~ wireshark/wsutil/strtoi.c:83:12: note: expanded from macro 'DEFINE_WS_STRTOI_BITS' if (val < 0) \ ~~~ ^ wireshark/wsutil/strtoi.c:115:1: warning: The left operand of '<' is a garbage value DEFINE_WS_STRTOI_BITS(8) ^~~~~~~~~~~~~~~~~~~~~~~~ wireshark/wsutil/strtoi.c:83:12: note: expanded from macro 'DEFINE_WS_STRTOI_BITS' if (val < 0) \ ~~~ ^ 3 warnings generated. Change-Id: I9eef0f2c0d4500531655a8b43509205a1f4e0684 Reviewed-on: https://code.wireshark.org/review/18640 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2016-10-27wsutil: add check for input pointers to ws_strtoi functions.Dario Lombardo1-0/+14
Change-Id: I7353a3b00392aa606fad04ef76e8b18ffbabbf5e Reviewed-on: https://code.wireshark.org/review/18449 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-09-16Add ws_hexstrtou{bits} and use ws_hexstrtou32 in androiddump.Guy Harris1-43/+63
Make the reply length unsigned - there's no reason for it to be signed. Change-Id: I5f4d1f027eeddee939547c052220efb89800f4b1 Reviewed-on: https://code.wireshark.org/review/17740 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-12Let strtoi with NULL endptr require no invalid charactersPeter Wu1-2/+2
If the caller is not interested in checking its end, then it probably wants a valid number only if the string contains a valid number. Add a shortcut for this. Change-Id: I39701bd445e29fb2606720b18ca3764c74a7255b Reviewed-on: https://code.wireshark.org/review/17658 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Guy Harris <guy@alum.mit.edu> Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-09-07Make the ws_strto* routines more like the strto* routines.Guy Harris1-12/+26
Not all uses of atoi() or various strto* routines in Wireshark expect the string to contain *only* a number, so not all uses should require that the byte after the number be a '\0'. Have the ws_strto* routines take a "pointer a pointer set to point to the character after the number" argument, and have the callers do the appropriate checks of the character after that. This fixes the VMS trace reading code so that it can read those files again. The get_ routines are handed command-line arguments, so they *do* expect the string to contain only a number; have them check to make sure the byte after the number is a '\0'. Change-Id: I46fc1bea7912b9278e385fe38491a0a2ad60d697 Reviewed-on: https://code.wireshark.org/review/17560 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-06Always set *cint before returning.Guy Harris1-0/+1
Change-Id: I333aef7d3fe4ad3bf7c2a4d7318766fcbd2e4cd2 Reviewed-on: https://code.wireshark.org/review/17539 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-06strtoi(.c): fix extra ';' outside of a function [-Wextra-semi]Alexis La Goutte1-6/+6
Change-Id: I2d92678b2117da732be309c2d430d0c97c7a7eed Reviewed-on: https://code.wireshark.org/review/17528 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Dario Lombardo <lomato@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-09-06Return the maximum or minimum value for ERANGE.Guy Harris1-5/+57
That way, for signed values, the caller knows whether ERANGE means "too large" or "too small"; this is analogous to what the C routines return. Change-Id: Ifc1fc4723733be606487093f8aa77ae2d89d2c40 Reviewed-on: https://code.wireshark.org/review/17512 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-06Check for signs in unsigned numbers and fail if we see one.Guy Harris1-0/+7
-1 is not an unsigned number. For that matter, neither is +1; "unsigned" means "without a sign", and they both have signs. ANSI C's strto{whatever} routines - even the ones that supposedly are for "unsigned" values - and the GLib routines modeled after them allow a leading sign, so we have to check ourselves. Change-Id: Ia0584bbf83394185cde88eec48efcdfa316f1c92 Reviewed-on: https://code.wireshark.org/review/17511 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-05wsutil: add string to integer conversion utilities.Dario Lombardo1-0/+122
In the current code many functions have been used for convertion (strtol, atoi, g_ascii_strtoll, etc). Those utilities want to be the only, shared, way to convert integers. Change-Id: I22ba1bf54e144e73a4728612a4437de5a2d339e2 Reviewed-on: https://code.wireshark.org/review/17414 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Roland Knall <rknall@gmail.com> Reviewed-by: Dario Lombardo <lomato@gmail.com>