From: Thomas Huth <thuth@redhat.com>
To: "Collin L. Walling" <walling@linux.vnet.ibm.com>,
Eric Blake <eblake@redhat.com>,
qemu-s390x@nongnu.org, qemu-devel@nongnu.org
Cc: frankja@linux.vnet.ibm.com, cohuck@redhat.com, david@redhat.com,
alifm@linux.vnet.ibm.com, borntraeger@de.ibm.com
Subject: Re: [Qemu-devel] [PATCH v3 1/8] s390-ccw: update libc
Date: Tue, 16 Jan 2018 11:00:54 +0100 [thread overview]
Message-ID: <272fa2f6-8a75-3c05-e373-d7d1b65a7e23@redhat.com> (raw)
In-Reply-To: <e0653416-ea6a-f801-2c30-4d01ed1fcf42@linux.vnet.ibm.com>
On 15.01.2018 18:23, Collin L. Walling wrote:
> On 01/15/2018 12:05 PM, Eric Blake wrote:
>> On 01/15/2018 10:44 AM, Collin L. Walling wrote:
[...]
>>> +/**
>>> + * atoi:
>>> + * @str: the string to be converted.
>>> + *
>>> + * Given a string @str, convert it to an integer. Any non-numerical
>>> value
>>> + * will terminate the conversion.
>>> + *
>>> + * Returns: an integer converted from the string @str.
>>> + */
>>> +int atoi(const char *str)
>>> +{
>>> + int i;
>>> + int val = 0;
>>> +
>>> + for (i = 0; str[i]; i++) {
>>> + char c = str[i];
>>> + if (!isdigit(c)) {
>>> + break;
>>> + }
>>> + val *= 10;
>>> + val += c - '0';
>> Silently gives garbage on integer overflow, but matches the fact that
>> POSIX atoi() can't flag errors. However, it does not handle leading
>> whitespace nor '-', which means it is NOT doing a POSIX-compatible
>> atoi() implementation; naming it atoi() is perhaps thus a disservice to
>> end users.
>
> Fair enough. Perhaps the "strtoi" convention suits this better.
Or maybe simply add an assert(str[0] != '-') for now. If we ever hit the
assert, we can still add the support for negative numbers if necessary.
>>> +static inline size_t strlen(const char *str)
>>> +{
>>> + size_t i;
>>> + for (i = 0; *str; i++) {
>>> + str++;
>>> + }
>>> + return i;
>> Again, not the fastest implementation, but that shouldn't matter.
Yes, indeed, speed does not really matter here for the some few bytes
that are handled during the life-time of the s390-ccw bios.
>>> +}
>>> +
>>> +static inline int isdigit(int c)
>>> +{
>>> + return (c >= '0') && (c <= '9');
>>> +}
>>> +
>>> +int atoi(const char *str);
>>> +char *itostr(int num, char *str, size_t len);
>>> +
>>> #endif
>
>
Thomas
next prev parent reply other threads:[~2018-01-16 10:01 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-15 16:44 [Qemu-devel] [PATCH v3 0/8] Interactive Boot Menu for DASD and SCSI Guests on s390x Collin L. Walling
2018-01-15 16:44 ` [Qemu-devel] [PATCH v3 1/8] s390-ccw: update libc Collin L. Walling
2018-01-15 17:05 ` Eric Blake
2018-01-15 17:23 ` Collin L. Walling
2018-01-16 10:00 ` Thomas Huth [this message]
2018-01-16 17:19 ` [Qemu-devel] [qemu-s390x] " Collin L. Walling
2018-01-16 11:07 ` Christian Borntraeger
2018-01-16 15:32 ` Collin L. Walling
2018-01-16 15:48 ` Thomas Huth
2018-01-15 16:44 ` [Qemu-devel] [PATCH v3 2/8] s390-ccw: ipl structs for eckd cdl/ldl Collin L. Walling
2018-01-16 12:32 ` Thomas Huth
2018-01-16 15:21 ` [Qemu-devel] [qemu-s390x] " Collin L. Walling
2018-01-15 16:44 ` [Qemu-devel] [PATCH v3 3/8] s390-ccw: parse and set boot menu options Collin L. Walling
2018-01-16 12:44 ` Thomas Huth
2018-01-16 15:26 ` [Qemu-devel] [qemu-s390x] " Collin L. Walling
2018-01-15 16:44 ` [Qemu-devel] [PATCH v3 4/8] s390-ccw: interactive boot menu for eckd dasd (menu setup) Collin L. Walling
2018-01-16 18:23 ` Thomas Huth
2018-01-16 19:37 ` [Qemu-devel] [qemu-s390x] " Collin L. Walling
2018-01-17 6:11 ` Thomas Huth
2018-01-17 12:12 ` Collin L. Walling
2018-01-15 16:44 ` [Qemu-devel] [PATCH v3 5/8] s390-ccw: interactive boot menu for eckd dasd (read stage2 data) Collin L. Walling
2018-01-17 8:38 ` Thomas Huth
2018-01-17 9:12 ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-01-17 12:29 ` Collin L. Walling
2018-01-15 16:44 ` [Qemu-devel] [PATCH v3 6/8] s390-ccw: interactive boot menu for eckd dasd (print menu) Collin L. Walling
2018-01-17 8:58 ` Thomas Huth
2018-01-15 16:44 ` [Qemu-devel] [PATCH v3 7/8] s390-ccw: interactive boot menu for eckd dasd (read input) Collin L. Walling
2018-01-17 10:10 ` Thomas Huth
2018-01-17 13:19 ` [Qemu-devel] [qemu-s390x] " Collin L. Walling
2018-01-15 16:44 ` [Qemu-devel] [PATCH v3 8/8] s390-ccw: interactive boot menu for scsi Collin L. Walling
2018-01-17 10:16 ` Thomas Huth
2018-01-15 16:58 ` [Qemu-devel] [PATCH v3 0/8] Interactive Boot Menu for DASD and SCSI Guests on s390x no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=272fa2f6-8a75-3c05-e373-d7d1b65a7e23@redhat.com \
--to=thuth@redhat.com \
--cc=alifm@linux.vnet.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=eblake@redhat.com \
--cc=frankja@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=walling@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).