[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [qemu-s390x] [PATCH v7 04/12] s390-ccw: update libc
From: |
Thomas Huth |
Subject: |
Re: [qemu-s390x] [PATCH v7 04/12] s390-ccw: update libc |
Date: |
Sat, 17 Feb 2018 08:48:02 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
On 16.02.2018 23:07, Collin L. Walling wrote:
[...]
> +/**
> + * uitoa:
> + * @num: an integer (base 10) to be converted.
> + * @str: a pointer to a string to store the conversion.
> + * @len: the length of the passed string.
> + *
> + * Given an integer @num, convert it to a string. The string @str must be
> + * allocated beforehand. The resulting string will be null terminated and
> + * returned. This function only handles numbers between 0 and UINT64_MAX
> + * inclusive.
> + *
> + * Returns: the string @str of the converted integer @num
> + */
> +char *uitoa(uint64_t num, char *str, size_t len)
> +{
> + size_t num_idx = 0;
> + uint64_t tmp = num;
> +
> + IPL_assert(str != NULL, "uitoa: no space allocated to store string");
> +
> + /* Get index to ones place */
> + while ((tmp /= 10) != 0) {
> + num_idx++;
> + }
> +
> + /* Check if we have enough space for num and null */
> + IPL_assert(len > num_idx, "uitoa: array too small for conversion");
Well, in v5 of this patch you've had "len >= num_idx + 1" where we
agreed that it was wrong. Now you have "len > num_idx" which is pretty
much the same. WTF?
I still think you need "len > num_idx + 1" here to properly take the
trailing NUL-byte into account properly. Please fix it!
Thomas
- Re: [qemu-s390x] [Qemu-devel] [PATCH v7 06/12] s390-ccw: parse and set boot menu options, (continued)
[qemu-s390x] [PATCH v7 01/12] s390-ccw: refactor boot map table code, Collin L. Walling, 2018/02/16
[qemu-s390x] [PATCH v7 03/12] s390-ccw: refactor IPL structs, Collin L. Walling, 2018/02/16
[qemu-s390x] [PATCH v7 02/12] s390-ccw: refactor eckd_block_num to use CHS, Collin L. Walling, 2018/02/16
[qemu-s390x] [PATCH v7 04/12] s390-ccw: update libc, Collin L. Walling, 2018/02/16
- Re: [qemu-s390x] [PATCH v7 04/12] s390-ccw: update libc,
Thomas Huth <=
- Re: [qemu-s390x] [PATCH v7 04/12] s390-ccw: update libc, Collin L. Walling, 2018/02/19
- Re: [qemu-s390x] [PATCH v7 04/12] s390-ccw: update libc, Thomas Huth, 2018/02/19
- Re: [qemu-s390x] [PATCH v7 04/12] s390-ccw: update libc, Collin L. Walling, 2018/02/19
- Re: [qemu-s390x] [Qemu-devel] [PATCH v7 04/12] s390-ccw: update libc, Collin L. Walling, 2018/02/19
- Re: [qemu-s390x] [Qemu-devel] [PATCH v7 04/12] s390-ccw: update libc, Eric Blake, 2018/02/19
- Re: [qemu-s390x] [Qemu-devel] [PATCH v7 04/12] s390-ccw: update libc, Thomas Huth, 2018/02/19
[qemu-s390x] [PATCH v7 05/12] s390-ccw: move auxiliary IPL data to separate location, Collin L. Walling, 2018/02/16