[lttng-dev] [PATCH lttng-tools] utils: Rework utils_parse_size_suffix

Thibault, Daniel Daniel.Thibault at drdc-rddc.gc.ca
Thu Apr 10 16:22:42 EDT 2014


----------------------------------------------------------------------
Date: Thu, 10 Apr 2014 14:43:38 -0400
From: Simon Marchi <simon.marchi at polymtl.ca>

>>>>   Should be "[...] should not begin with '-' [...]" (although it is 
>>>> true the size string should not *contain*, the test is only for 
>>>> *begins with*)

> I meant for it to search in the whole string, and that is what I think strchr does.

Oops, my bad.

> [...]
> +       if (num_end == str) {
> +               /* strtoull parsed nothing, not good. */
> +               DBG("utils_parse_size_suffix: strtoull had nothing good to parse.\n");
> +               ret = -1;
> +               goto end;
> +       }
>
>>>>   "utils_parse_size_suffix: zero-length size string." would be clearer.  Also note that the preceding DBG strings did not end with '\n'.

> This test indeed will catch zero-length strings. However, if you pass "hello", or "k", strtoull will just parse 0 characters and return the value 0. This test is for these cases as well, which are not zero-length strings. I agree that it's not very clear, but I have nothing better...

How about " utils_parse_size_suffix: size string does not begin with a number."?

Daniel U. Thibault
Protection des systèmes et contremesures (PSC) | Systems Protection & Countermeasures (SPC)
Cyber sécurité pour les missions essentielles (CME) | Mission Critical Cyber Security (MCCS)
R & D pour la défense Canada - Valcartier (RDDC Valcartier) | Defence R&D Canada - Valcartier (DRDC Valcartier)
2459 route de la Bravoure
Québec QC  G3J 1X5
CANADA
Vox : (418) 844-4000 x4245
Fax : (418) 844-4538
NAC : 918V QSDJ <http://www.travelgis.com/map.asp?addr=918V%20QSDJ>
Gouvernement du Canada | Government of Canada
<http://www.valcartier.drdc-rddc.gc.ca/>



More information about the lttng-dev mailing list