Re: [systemd-devel] How to handle untagged hexvalues in systemd code?
On Mo, 15.01.18 18:44, Olaf Hering (o...@aepfle.de) wrote: > I submitted a correct and tested patch via > https://github.com/systemd/systemd/pull/7581, which was using > sscanf("0028f0", "%x",). During discussion I was soft-forced to > use systemd helper functions. These (strtoull based) helpers expect > "0x...", which sysfs does not provide. As a result 575e658 is > broken. My fault, I did not doublecheck the updated submission... > > So, how is one supposed to handle untagged hexvalues? Invent a new > helper, or prepend "0x" if missing, or just use sscanf? We have very few cases of that so far, hence there is no helper. Adding a helper is probably worth it if there are multiple users and until then sscanf() is fine, as long as it is done safely with all parsing error caught. We have the safe_atou() and friends mostly because parsing things in C with strtoul() is really nasty if you want to catch all errors properly. libc strtoul() is not precisely an easy-to-use API. Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] How to handle untagged hexvalues in systemd code?
On Mon, Jan 15, 2018 at 06:44:41PM +0100, Olaf Hering wrote: > I submitted a correct and tested patch via > https://github.com/systemd/systemd/pull/7581, which was using > sscanf("0028f0", "%x",). During discussion I was soft-forced to use > systemd helper functions. These (strtoull based) helpers expect "0x...", > which sysfs does not provide. As a result 575e658 is broken. My fault, I did > not doublecheck the updated submission... > I merged the PR to use sscanf. After all, it works now, it's unlikely for the kernel to change that to something incompatible. Zbyszek > So, how is one supposed to handle untagged hexvalues? Invent a new helper, or > prepend "0x" if missing, or just use sscanf? > > Olaf > ___ > systemd-devel mailing list > systemd-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/systemd-devel ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] How to handle untagged hexvalues in systemd code?
I submitted a correct and tested patch via https://github.com/systemd/systemd/pull/7581, which was using sscanf("0028f0", "%x",). During discussion I was soft-forced to use systemd helper functions. These (strtoull based) helpers expect "0x...", which sysfs does not provide. As a result 575e658 is broken. My fault, I did not doublecheck the updated submission... So, how is one supposed to handle untagged hexvalues? Invent a new helper, or prepend "0x" if missing, or just use sscanf? Olaf pgpxbJPIkHTEH.pgp Description: Digitale Signatur von OpenPGP ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel