Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 20559a8

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 5c24c61 commit 20559a8

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/timezone/zic.c

+11-12
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ static ptrdiff_t const PTRDIFF_MAX = MAXVAL(ptrdiff_t, TYPE_BIT(ptrdiff_t));
4848
#endif
4949

5050
/* The type and printf format for line numbers. */
51-
typedef int lineno;
51+
typedef int lineno_t;
5252
#define PRIdLINENO "d"
5353

5454
struct rule
5555
{
5656
const char *r_filename;
57-
lineno r_linenum;
57+
lineno_t r_linenum;
5858
const char *r_name;
5959

6060
zic_t r_loyear; /* for example, 1986 */
@@ -91,7 +91,7 @@ struct rule
9191
struct zone
9292
{
9393
const char *z_filename;
94-
lineno z_linenum;
94+
lineno_t z_linenum;
9595

9696
const char *z_name;
9797
zic_t z_gmtoff;
@@ -169,7 +169,7 @@ static int leapcnt;
169169
static bool leapseen;
170170
static zic_t leapminyear;
171171
static zic_t leapmaxyear;
172-
static lineno linenum;
172+
static lineno_t linenum;
173173
static int max_abbrvar_len = PERCENT_Z_LEN_BOUND;
174174
static int max_format_len;
175175
static zic_t max_year;
@@ -178,7 +178,7 @@ static bool noise;
178178
static bool print_abbrevs;
179179
static zic_t print_cutoff;
180180
static const char *rfilename;
181-
static lineno rlinenum;
181+
static lineno_t rlinenum;
182182
static const char *progname;
183183
static ptrdiff_t timecnt;
184184
static ptrdiff_t timecnt_alloc;
@@ -276,7 +276,7 @@ static ptrdiff_t nzones_alloc;
276276
struct link
277277
{
278278
const char *l_filename;
279-
lineno l_linenum;
279+
lineno_t l_linenum;
280280
const char *l_from;
281281
const char *l_to;
282282
};
@@ -430,14 +430,13 @@ ecpyalloc(char const * str)
430430
}
431431

432432
static void *
433-
growalloc(void *ptr, size_t itemsize, ptrdiff_t nitems, ptrdiff_t * nitems_alloc)
433+
growalloc(void *ptr, size_t itemsize, ptrdiff_t nitems, ptrdiff_t *nitems_alloc)
434434
{
435435
if (nitems < *nitems_alloc)
436436
return ptr;
437437
else
438438
{
439-
ptrdiff_t nitems_max = PTRDIFF_MAX - WORK_AROUND_QTBUG_53071;
440-
ptrdiff_t amax = nitems_max < SIZE_MAX ? nitems_max : SIZE_MAX;
439+
ptrdiff_t amax = PTRDIFF_MAX - WORK_AROUND_QTBUG_53071;
441440

442441
if ((amax - 1) / 3 * 2 < *nitems_alloc)
443442
memory_exhausted(_("integer overflow"));
@@ -451,7 +450,7 @@ growalloc(void *ptr, size_t itemsize, ptrdiff_t nitems, ptrdiff_t * nitems_alloc
451450
*/
452451

453452
static void
454-
eats(char const * name, lineno num, char const * rname, lineno rnum)
453+
eats(char const * name, lineno_t num, char const * rname, lineno_t rnum)
455454
{
456455
filename = name;
457456
linenum = num;
@@ -460,7 +459,7 @@ eats(char const * name, lineno num, char const * rname, lineno rnum)
460459
}
461460

462461
static void
463-
eat(char const * name, lineno num)
462+
eat(char const * name, lineno_t num)
464463
{
465464
eats(name, num, NULL, -1);
466465
}
@@ -1157,7 +1156,7 @@ infile(const char *name)
11571156
const struct lookup *lp;
11581157
int nfields;
11591158
bool wantcont;
1160-
lineno num;
1159+
lineno_t num;
11611160
char buf[BUFSIZ];
11621161

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

0 commit comments

Comments
 (0)