From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
Cc: | Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Fix inappropriate uses of atol() |
Date: | 2024-08-03 15:20:13 |
Message-ID: | 4169218.1722698413@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Heikki Linnakangas <hlinnaka(at)iki(dot)fi> writes:
> On 03/08/2024 14:04, Peter Eisentraut wrote:
>> I noticed (during [0]) to some uses of the function atol() seem
>> inappropriate.
> +1 except for this one:
>> /* If we have just one character this is not a string */
>> - if (atol(p->type->size) == 1)
>> + if (atoi(p->type->size) == 1)
>> mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
How about
- if (atol(p->type->size) == 1)
+ if (strcmp(p->type->size, "1") == 0)
? I've not actually tested, but this should catch the cases the
warning is meant to catch while not complaining about any of the
examples you give. I'm not sure if leading/trailing spaces
would fool it (i.e., "char foo[ 1 ];"). But even if they do,
that doesn't seem disastrous.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2024-08-03 15:27:00 | Re: Fix inappropriate uses of atol() |
Previous Message | Melanie Plageman | 2024-08-03 15:14:20 | Re: Draft release notes for next week's releases are up |