Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #164079
| Path | csiph.com!aioe.org!Q29r0ETj/jjLPjDuGSMcjw.user.46.165.242.75.POSTED!not-for-mail |
|---|---|
| From | Meredith Montgomery <mmontgomery@levado.to> |
| Newsgroups | comp.lang.c |
| Subject | Re: unsafe C |
| Date | Sat, 25 Dec 2021 21:42:00 -0300 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <86lf0819k7.fsf@levado.to> (permalink) |
| References | <d8227134-6e0b-486e-af91-aeece50a466bn@googlegroups.com> <54ebbb14-cb1e-4dd5-a4ec-9dd086e0eaa3n@googlegroups.com> <86wnk153br.fsf@levado.to> <pos-20211219061641@ram.dialup.fu-berlin.de> <86sfug19l8.fsf@levado.to> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | gioia.aioe.org; logging-data="21226"; posting-host="Q29r0ETj/jjLPjDuGSMcjw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; |
| X-Notice | Filtered by postfilter v. 0.9.2 |
| Cancel-Lock | sha1:PpsWez++/V2zEb0zvcf3OeEG5f8= |
| Xref | csiph.com comp.lang.c:164079 |
Show key headers only | View raw
Meredith Montgomery <mmontgomery@levado.to> writes:
> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>
>> Meredith Montgomery <mmontgomery@levado.to> writes:
>>>> it is funny that this is a warning and not an error.
>>
>>>int scan_ulong(register char *s, register unsigned long *u)
>>>{
>>> register unsigned int pos;
>> ...
>>> return pos;
>>>}
>>
>> It returns the /unsigned/ int "pos", but its return type is
>> declared /signed/ int?
>>
>> /u/ is accessed at most once in the function, but declared
>> "register"?
>
> Let's see. I don't think I would've changed that much, but I might.
> Lol. I did. I can't even copy properly! Thanks for spotting that.
>
> Hm, wait! The check for overflow is not his. It's mine. Alas, memory
> failing me. Daniel J. Bernstein, sorry about that.
>
> /* Public domain. */
>
> #include "scan.h"
>
> unsigned int scan_ulong(register const char *s,register unsigned long *u)
> {
> register unsigned int pos = 0;
> register unsigned long result = 0;
> register unsigned long c;
> while ((c = (unsigned long) (unsigned char) (s[pos] - '0')) < 10) {
> result = result * 10 + c;
> ++pos;
> }
> *u = result;
> return pos;
> }
>
> But, yes, he did qualify u with ``register''.
By the way, that's src/scan_ulong.c in daemontools 0.76.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
unsafe C Thiago Adams <thiago.adams@gmail.com> - 2021-12-17 12:13 -0800
Re: unsafe C Thiago Adams <thiago.adams@gmail.com> - 2021-12-17 12:16 -0800
Re: unsafe C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-12-17 12:25 -0800
Re: unsafe C Meredith Montgomery <mmontgomery@levado.to> - 2021-12-18 12:40 -0300
Re: unsafe C Meredith Montgomery <mmontgomery@levado.to> - 2021-12-25 21:41 -0300
Re: unsafe C Meredith Montgomery <mmontgomery@levado.to> - 2021-12-25 21:42 -0300
Re: unsafe C Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-12-18 12:29 -0800
Re: unsafe C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-12-17 12:20 -0800
Re: unsafe C Thiago Adams <thiago.adams@gmail.com> - 2021-12-17 12:29 -0800
Re: unsafe C Peter 'Shaggy' Haywood <phaywood@alphalink.com.au> - 2021-12-19 17:16 +1100
Re: unsafe C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-12-19 13:32 -0800
Re: unsafe C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-12-17 20:30 +0000
Re: unsafe C Thiago Adams <thiago.adams@gmail.com> - 2021-12-17 12:35 -0800
csiph-web