lib/strtox: introduce kstrtoull_suffix() helper
Quoted 2 lines
Just as mentioned in the comment of
memparse(), thesimple_stroull()usage can lead to overflow all by itself.
which is the root cause...
I don't like one char suffixes. They are easy to integrate but then the _real_ suffixes are "MiB", "GiB", etc.
If you care only about memparse(), then using _parse_integer() can be arranged. I don't see why not.
Quoted 10 lines · Alexey Dobriyan
Quoted 2 lines
Just as mentioned in the comment of
memparse(), thesimple_stroull()usage can lead to overflow all by itself.which is the root cause...
I don't like one char suffixes. They are easy to integrate but then the _real_ suffixes are "MiB", "GiB", etc.
If you care only about
memparse(), then using_parse_integer()can be arranged. I don't see why not.
Well, personally speaking I don't think we should even support the suffix at all, at least for the only two usage inside btrfs.
But unfortunately I'm not the one to do the final call, and the final call is to keep the suffix behavior...
And indeed using _parse_integer() with _parse_interger_fixup_radix() would be better, as we don't need to extend the _kstrtoull() code base.
Thanks,
Qu
Quoted 12 lines · Qu Wenruo
Quoted 10 lines · Alexey Dobriyan
Quoted 2 lines
Just as mentioned in the comment of
memparse(), thesimple_stroull()usage can lead to overflow all by itself.which is the root cause...
I don't like one char suffixes. They are easy to integrate but then the _real_ suffixes are "MiB", "GiB", etc.
If you care only about
memparse(), then using_parse_integer()can be arranged. I don't see why not.
Quoted 8 lines
Well, personally speaking I don't think we should even support the suffix at all, at least for the only two usage inside btrfs.
But unfortunately I'm not the one to do the final call, and the final call is to keep the suffix behavior...
And indeed using
_parse_integer()with_parse_interger_fixup_radix()would be better, as we don't need to extend the_kstrtoull()code base.
My comment on the first patch got vanished due to my MTA issues, but I'll try to summarize my point here.
First of all, I do not like the naming, it's too vague. What kind of suffix? Do we suppose to have suffix in the input? What will be the behaviour w/o suffix? And so on...
Second, if it's a problem in memparse(), just fix it and that's all.
Third, as Alexey said, we have metric and byte suffixes and they are different. Supporting one without the other is just adding to the existing confusion.
Last, but not least, we do NOT accept new code in the lib/ without test cases.
So, that said here is my formal NAK for this series (at least in this form).
P.S> The Subject should start with either kstrtox: or lib/kstrtox.c.
Signature · 2 lines
With Best Regards, Andy Shevchenko