On 02/05/2016 01:56 AM, Alex Bennée wrote:
+ gchar *range_op = g_strstr_len(r, -1, "-");
This is strchr.
+ range_op = g_strstr_len(r, -1, ".");
Or at least if you're going to make use of strstr, search for "..".
+ g_strdelimit(range_val, ".", ' ');
Cause this is just weird. It accepts "1+.2" just the same as "1..2".
+ err = qemu_strtoul(r, NULL, 0, &range.begin);
This should be strtoull. You probably broke 32-bit compilation here.
+ case '+': + { + unsigned long len; + err |= qemu_strtoul(range_val, NULL, 0, &len); + range.end = range.begin + len; + break; + } + case '-': + { + unsigned long len; + err |= qemu_strtoul(range_val, NULL, 0, &len); + range.end = range.begin; + range.begin = range.end - len; + break; + }
Both of these have off-by-one bugs, since end is inclusive.
+ case '.': + err |= qemu_strtoul(range_val, NULL, 0, &range.end); + break;
I'd think multiple dot detection belongs here, and you need not smash them to ' ' but merely notice that there are two of them and then strtoull range_val+1.
r~