Skip to content

Commit 3a8f24a

Browse files
committed
More zic cleanup.
The workaround the IANA guys chose to get rid of the clang warning we'd silenced in commit 23ed2ba turns out not to satisfy Coverity. Go back to the previous solution, ie, remove the useless comparison to SIZE_MAX. (In principle, there could be machines out there where it's not useless because ptrdiff_t is wider than size_t. But the whole thing is pretty academic anyway, as we could never approach this limit for any sane estimate of the amount of data that zic will ever be asked to work with.) Also, s/lineno/lineno_t/g, because if we accept their decision to start using "lineno" as a typedef, it is going to have very unpleasant consequences in our next pgindent run. Noted that while fooling with pltcl yesterday.
1 parent 22b1207 commit 3a8f24a

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/timezone/zic.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ static ptrdiff_t const PTRDIFF_MAX = MAXVAL(ptrdiff_t, TYPE_BIT(ptrdiff_t));
5757
#endif
5858

5959
/* The type and printf format for line numbers. */
60-
typedef int lineno;
60+
typedef int lineno_t;
6161
#define PRIdLINENO "d"
6262

6363
struct rule
6464
{
6565
const char *r_filename;
66-
lineno r_linenum;
66+
lineno_t r_linenum;
6767
const char *r_name;
6868

6969
zic_t r_loyear; /* for example, 1986 */
@@ -100,7 +100,7 @@ struct rule
100100
struct zone
101101
{
102102
const char *z_filename;
103-
lineno z_linenum;
103+
lineno_t z_linenum;
104104

105105
const char *z_name;
106106
zic_t z_gmtoff;
@@ -181,7 +181,7 @@ static int leapcnt;
181181
static bool leapseen;
182182
static zic_t leapminyear;
183183
static zic_t leapmaxyear;
184-
static lineno linenum;
184+
static lineno_t linenum;
185185
static int max_abbrvar_len = PERCENT_Z_LEN_BOUND;
186186
static int max_format_len;
187187
static zic_t max_year;
@@ -190,7 +190,7 @@ static bool noise;
190190
static bool print_abbrevs;
191191
static zic_t print_cutoff;
192192
static const char *rfilename;
193-
static lineno rlinenum;
193+
static lineno_t rlinenum;
194194
static const char *progname;
195195
static ptrdiff_t timecnt;
196196
static ptrdiff_t timecnt_alloc;
@@ -288,7 +288,7 @@ static ptrdiff_t nzones_alloc;
288288
struct link
289289
{
290290
const char *l_filename;
291-
lineno l_linenum;
291+
lineno_t l_linenum;
292292
const char *l_from;
293293
const char *l_to;
294294
};
@@ -442,14 +442,13 @@ ecpyalloc(char const * str)
442442
}
443443

444444
static void *
445-
growalloc(void *ptr, size_t itemsize, ptrdiff_t nitems, ptrdiff_t * nitems_alloc)
445+
growalloc(void *ptr, size_t itemsize, ptrdiff_t nitems, ptrdiff_t *nitems_alloc)
446446
{
447447
if (nitems < *nitems_alloc)
448448
return ptr;
449449
else
450450
{
451-
ptrdiff_t nitems_max = PTRDIFF_MAX - WORK_AROUND_QTBUG_53071;
452-
ptrdiff_t amax = nitems_max < SIZE_MAX ? nitems_max : SIZE_MAX;
451+
ptrdiff_t amax = PTRDIFF_MAX - WORK_AROUND_QTBUG_53071;
453452

454453
if ((amax - 1) / 3 * 2 < *nitems_alloc)
455454
memory_exhausted(_("integer overflow"));
@@ -463,7 +462,7 @@ growalloc(void *ptr, size_t itemsize, ptrdiff_t nitems, ptrdiff_t * nitems_alloc
463462
*/
464463

465464
static void
466-
eats(char const * name, lineno num, char const * rname, lineno rnum)
465+
eats(char const * name, lineno_t num, char const * rname, lineno_t rnum)
467466
{
468467
filename = name;
469468
linenum = num;
@@ -472,7 +471,7 @@ eats(char const * name, lineno num, char const * rname, lineno rnum)
472471
}
473472

474473
static void
475-
eat(char const * name, lineno num)
474+
eat(char const * name, lineno_t num)
476475
{
477476
eats(name, num, NULL, -1);
478477
}
@@ -1169,7 +1168,7 @@ infile(const char *name)
11691168
const struct lookup *lp;
11701169
int nfields;
11711170
bool wantcont;
1172-
lineno num;
1171+
lineno_t num;
11731172
char buf[BUFSIZ];
11741173

11751174
if (strcmp(name, "-") == 0)

0 commit comments

Comments
 (0)