diff options
| author | Paul Eggert | 2025-11-20 08:46:44 -0800 |
|---|---|---|
| committer | Paul Eggert | 2025-11-20 09:11:59 -0800 |
| commit | 2cc6c812788281c05ca9687afd7bedf597b1e942 (patch) | |
| tree | 2d998ed896f38fe92ba260240075d1860709aba4 /lib | |
| parent | cada1c3192902136214e60b82fd7f9116bc88792 (diff) | |
| download | emacs-2cc6c812788281c05ca9687afd7bedf597b1e942.tar.gz emacs-2cc6c812788281c05ca9687afd7bedf597b1e942.zip | |
Update from Gnulib by running admin/merge-gnulib
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/acl-internal.c | 33 | ||||
| -rw-r--r-- | lib/diffseq.h | 238 | ||||
| -rw-r--r-- | lib/fcntl.c | 3 | ||||
| -rw-r--r-- | lib/fcntl.in.h | 9 | ||||
| -rw-r--r-- | lib/file-has-acl.c | 8 | ||||
| -rw-r--r-- | lib/ftoastr.c | 3 | ||||
| -rw-r--r-- | lib/getdtablesize.c | 11 | ||||
| -rw-r--r-- | lib/getloadavg.c | 8 | ||||
| -rw-r--r-- | lib/group-member.c | 7 | ||||
| -rw-r--r-- | lib/intprops-internal.h | 8 | ||||
| -rw-r--r-- | lib/memrchr.c | 14 | ||||
| -rw-r--r-- | lib/mktime.c | 6 | ||||
| -rw-r--r-- | lib/nproc.c | 16 | ||||
| -rw-r--r-- | lib/pselect.c | 4 | ||||
| -rw-r--r-- | lib/set-permissions.c | 8 | ||||
| -rw-r--r-- | lib/sha1.c | 3 | ||||
| -rw-r--r-- | lib/sha256.c | 9 | ||||
| -rw-r--r-- | lib/sha512.c | 9 | ||||
| -rw-r--r-- | lib/sig2str.c | 6 | ||||
| -rw-r--r-- | lib/stat-time.h | 3 | ||||
| -rw-r--r-- | lib/str-two-way.h | 9 | ||||
| -rw-r--r-- | lib/strftime.c | 65 | ||||
| -rw-r--r-- | lib/strnlen.c | 3 | ||||
| -rw-r--r-- | lib/strtol.c | 5 | ||||
| -rw-r--r-- | lib/sys_select.in.h | 3 | ||||
| -rw-r--r-- | lib/tempname.c | 3 |
26 files changed, 237 insertions, 257 deletions
diff --git a/lib/acl-internal.c b/lib/acl-internal.c index b8a6ed06c31..7d7cbb79818 100644 --- a/lib/acl-internal.c +++ b/lib/acl-internal.c | |||
| @@ -161,9 +161,7 @@ acl_default_nontrivial (acl_t acl) | |||
| 161 | int | 161 | int |
| 162 | acl_nontrivial (int count, aclent_t *entries) | 162 | acl_nontrivial (int count, aclent_t *entries) |
| 163 | { | 163 | { |
| 164 | int i; | 164 | for (int i = 0; i < count; i++) |
| 165 | |||
| 166 | for (i = 0; i < count; i++) | ||
| 167 | { | 165 | { |
| 168 | aclent_t *ace = &entries[i]; | 166 | aclent_t *ace = &entries[i]; |
| 169 | 167 | ||
| @@ -192,8 +190,6 @@ acl_nontrivial (int count, aclent_t *entries) | |||
| 192 | int | 190 | int |
| 193 | acl_ace_nontrivial (int count, ace_t *entries) | 191 | acl_ace_nontrivial (int count, ace_t *entries) |
| 194 | { | 192 | { |
| 195 | int i; | ||
| 196 | |||
| 197 | /* The flags in the ace_t structure changed in a binary incompatible way | 193 | /* The flags in the ace_t structure changed in a binary incompatible way |
| 198 | when ACL_NO_TRIVIAL etc. were introduced in <sys/acl.h> version 1.15. | 194 | when ACL_NO_TRIVIAL etc. were introduced in <sys/acl.h> version 1.15. |
| 199 | How to distinguish the two conventions at runtime? | 195 | How to distinguish the two conventions at runtime? |
| @@ -202,7 +198,7 @@ acl_ace_nontrivial (int count, ace_t *entries) | |||
| 202 | convention, these values are not used. */ | 198 | convention, these values are not used. */ |
| 203 | int old_convention = 0; | 199 | int old_convention = 0; |
| 204 | 200 | ||
| 205 | for (i = 0; i < count; i++) | 201 | for (int i = 0; i < count; i++) |
| 206 | if (entries[i].a_flags & (OLD_ACE_OWNER | OLD_ACE_GROUP | OLD_ACE_OTHER)) | 202 | if (entries[i].a_flags & (OLD_ACE_OWNER | OLD_ACE_GROUP | OLD_ACE_OTHER)) |
| 207 | { | 203 | { |
| 208 | old_convention = 1; | 204 | old_convention = 1; |
| @@ -211,7 +207,7 @@ acl_ace_nontrivial (int count, ace_t *entries) | |||
| 211 | 207 | ||
| 212 | if (old_convention) | 208 | if (old_convention) |
| 213 | /* Running on Solaris 10. */ | 209 | /* Running on Solaris 10. */ |
| 214 | for (i = 0; i < count; i++) | 210 | for (int i = 0; i < count; i++) |
| 215 | { | 211 | { |
| 216 | ace_t *ace = &entries[i]; | 212 | ace_t *ace = &entries[i]; |
| 217 | 213 | ||
| @@ -238,7 +234,7 @@ acl_ace_nontrivial (int count, ace_t *entries) | |||
| 238 | 0 /* everyone@ allow */ | 234 | 0 /* everyone@ allow */ |
| 239 | }; | 235 | }; |
| 240 | 236 | ||
| 241 | for (i = 0; i < count; i++) | 237 | for (int i = 0; i < count; i++) |
| 242 | { | 238 | { |
| 243 | ace_t *ace = &entries[i]; | 239 | ace_t *ace = &entries[i]; |
| 244 | unsigned int index1; | 240 | unsigned int index1; |
| @@ -374,12 +370,10 @@ acl_ace_nontrivial (int count, ace_t *entries) | |||
| 374 | int | 370 | int |
| 375 | acl_nontrivial (int count, struct acl_entry *entries) | 371 | acl_nontrivial (int count, struct acl_entry *entries) |
| 376 | { | 372 | { |
| 377 | int i; | ||
| 378 | |||
| 379 | if (count > 3) | 373 | if (count > 3) |
| 380 | return 1; | 374 | return 1; |
| 381 | 375 | ||
| 382 | for (i = 0; i < count; i++) | 376 | for (int i = 0; i < count; i++) |
| 383 | { | 377 | { |
| 384 | struct acl_entry *ace = &entries[i]; | 378 | struct acl_entry *ace = &entries[i]; |
| 385 | 379 | ||
| @@ -396,9 +390,7 @@ acl_nontrivial (int count, struct acl_entry *entries) | |||
| 396 | int | 390 | int |
| 397 | aclv_nontrivial (int count, struct acl *entries) | 391 | aclv_nontrivial (int count, struct acl *entries) |
| 398 | { | 392 | { |
| 399 | int i; | 393 | for (int i = 0; i < count; i++) |
| 400 | |||
| 401 | for (i = 0; i < count; i++) | ||
| 402 | { | 394 | { |
| 403 | struct acl *ace = &entries[i]; | 395 | struct acl *ace = &entries[i]; |
| 404 | 396 | ||
| @@ -424,10 +416,8 @@ int | |||
| 424 | acl_nontrivial (struct acl *a) | 416 | acl_nontrivial (struct acl *a) |
| 425 | { | 417 | { |
| 426 | /* The normal way to iterate through an ACL is like this: | 418 | /* The normal way to iterate through an ACL is like this: |
| 427 | struct acl_entry *ace; | 419 | for (struct acl_entry *ace = a->acl_ext; ace != acl_last (a); ace = acl_nxt (ace)) |
| 428 | for (ace = a->acl_ext; ace != acl_last (a); ace = acl_nxt (ace)) | ||
| 429 | { | 420 | { |
| 430 | struct ace_id *aei; | ||
| 431 | switch (ace->ace_type) | 421 | switch (ace->ace_type) |
| 432 | { | 422 | { |
| 433 | case ACC_PERMIT: | 423 | case ACC_PERMIT: |
| @@ -435,7 +425,7 @@ acl_nontrivial (struct acl *a) | |||
| 435 | case ACC_SPECIFY: | 425 | case ACC_SPECIFY: |
| 436 | ...; | 426 | ...; |
| 437 | } | 427 | } |
| 438 | for (aei = ace->ace_id; aei != id_last (ace); aei = id_nxt (aei)) | 428 | for (struct ace_id *aei = ace->ace_id; aei != id_last (ace); aei = id_nxt (aei)) |
| 439 | ... | 429 | ... |
| 440 | } | 430 | } |
| 441 | */ | 431 | */ |
| @@ -453,9 +443,8 @@ acl_nfs4_nontrivial (nfs4_acl_int_t *a) | |||
| 453 | return (a->aclEntryN > 0 ? 1 : 0); | 443 | return (a->aclEntryN > 0 ? 1 : 0); |
| 454 | # else | 444 | # else |
| 455 | int count = a->aclEntryN; | 445 | int count = a->aclEntryN; |
| 456 | int i; | ||
| 457 | 446 | ||
| 458 | for (i = 0; i < count; i++) | 447 | for (int i = 0; i < count; i++) |
| 459 | { | 448 | { |
| 460 | nfs4_ace_int_t *ace = &a->aclEntry[i]; | 449 | nfs4_ace_int_t *ace = &a->aclEntry[i]; |
| 461 | 450 | ||
| @@ -484,9 +473,7 @@ acl_nfs4_nontrivial (nfs4_acl_int_t *a) | |||
| 484 | int | 473 | int |
| 485 | acl_nontrivial (int count, struct acl *entries) | 474 | acl_nontrivial (int count, struct acl *entries) |
| 486 | { | 475 | { |
| 487 | int i; | 476 | for (int i = 0; i < count; i++) |
| 488 | |||
| 489 | for (i = 0; i < count; i++) | ||
| 490 | { | 477 | { |
| 491 | struct acl *ace = &entries[i]; | 478 | struct acl *ace = &entries[i]; |
| 492 | 479 | ||
diff --git a/lib/diffseq.h b/lib/diffseq.h index 914bc643bb4..b4959813d7f 100644 --- a/lib/diffseq.h +++ b/lib/diffseq.h | |||
| @@ -286,160 +286,156 @@ diag (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim, bool find_minimal, | |||
| 286 | } | 286 | } |
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | if (find_minimal) | 289 | if (!find_minimal) |
| 290 | continue; | 290 | { |
| 291 | |||
| 292 | #ifdef USE_HEURISTIC | 291 | #ifdef USE_HEURISTIC |
| 293 | bool heuristic = ctxt->heuristic; | 292 | bool heuristic = ctxt->heuristic; |
| 294 | #else | 293 | #else |
| 295 | bool heuristic = false; | 294 | bool heuristic = false; |
| 296 | #endif | 295 | #endif |
| 297 | 296 | ||
| 298 | /* Heuristic: check occasionally for a diagonal that has made lots | 297 | /* Heuristic: check occasionally for a diagonal that has made lots |
| 299 | of progress compared with the edit distance. If we have any | 298 | of progress compared with the edit distance. If we have any |
| 300 | such, find the one that has made the most progress and return it | 299 | such, find the one that has made the most progress and return it |
| 301 | as if it had succeeded. | 300 | as if it had succeeded. |
| 302 | 301 | ||
| 303 | With this heuristic, for vectors with a constant small density | 302 | With this heuristic, for vectors with a constant small density |
| 304 | of changes, the algorithm is linear in the vector size. */ | 303 | of changes, the algorithm is linear in the vector size. */ |
| 305 | |||
| 306 | if (200 < c && big_snake && heuristic) | ||
| 307 | { | ||
| 308 | { | ||
| 309 | OFFSET best = 0; | ||
| 310 | 304 | ||
| 311 | for (d = fmax; d >= fmin; d -= 2) | 305 | if (200 < c && big_snake && heuristic) |
| 306 | { | ||
| 312 | { | 307 | { |
| 313 | OFFSET dd = d - fmid; | 308 | OFFSET best = 0; |
| 314 | OFFSET x = fd[d]; | ||
| 315 | OFFSET y = x - d; | ||
| 316 | OFFSET v = (x - xoff) * 2 - dd; | ||
| 317 | 309 | ||
| 318 | if (v > 12 * (c + (dd < 0 ? -dd : dd))) | 310 | for (d = fmax; d >= fmin; d -= 2) |
| 319 | { | 311 | { |
| 320 | if (v > best | 312 | OFFSET dd = d - fmid; |
| 321 | && xoff + SNAKE_LIMIT <= x && x < xlim | 313 | OFFSET x = fd[d]; |
| 322 | && yoff + SNAKE_LIMIT <= y && y < ylim) | 314 | OFFSET y = x - d; |
| 315 | OFFSET v = (x - xoff) * 2 - dd; | ||
| 316 | |||
| 317 | if (v > 12 * (c + (dd < 0 ? -dd : dd))) | ||
| 323 | { | 318 | { |
| 324 | /* We have a good enough best diagonal; now insist | 319 | if (v > best |
| 325 | that it end with a significant snake. */ | 320 | && xoff + SNAKE_LIMIT <= x && x < xlim |
| 326 | int k; | 321 | && yoff + SNAKE_LIMIT <= y && y < ylim) |
| 327 | 322 | { | |
| 328 | for (k = 1; XREF_YREF_EQUAL (x - k, y - k); k++) | 323 | /* We have a good enough best diagonal; now insist |
| 329 | if (k == SNAKE_LIMIT) | 324 | that it end with a significant snake. */ |
| 330 | { | 325 | for (int k = 1; XREF_YREF_EQUAL (x - k, y - k); k++) |
| 331 | best = v; | 326 | if (k == SNAKE_LIMIT) |
| 332 | part->xmid = x; | 327 | { |
| 333 | part->ymid = y; | 328 | best = v; |
| 334 | break; | 329 | part->xmid = x; |
| 335 | } | 330 | part->ymid = y; |
| 331 | break; | ||
| 332 | } | ||
| 333 | } | ||
| 336 | } | 334 | } |
| 337 | } | 335 | } |
| 336 | if (best > 0) | ||
| 337 | { | ||
| 338 | part->lo_minimal = true; | ||
| 339 | part->hi_minimal = false; | ||
| 340 | return; | ||
| 341 | } | ||
| 338 | } | 342 | } |
| 339 | if (best > 0) | ||
| 340 | { | ||
| 341 | part->lo_minimal = true; | ||
| 342 | part->hi_minimal = false; | ||
| 343 | return; | ||
| 344 | } | ||
| 345 | } | ||
| 346 | |||
| 347 | { | ||
| 348 | OFFSET best = 0; | ||
| 349 | 343 | ||
| 350 | for (d = bmax; d >= bmin; d -= 2) | ||
| 351 | { | 344 | { |
| 352 | OFFSET dd = d - bmid; | 345 | OFFSET best = 0; |
| 353 | OFFSET x = bd[d]; | ||
| 354 | OFFSET y = x - d; | ||
| 355 | OFFSET v = (xlim - x) * 2 + dd; | ||
| 356 | 346 | ||
| 357 | if (v > 12 * (c + (dd < 0 ? -dd : dd))) | 347 | for (d = bmax; d >= bmin; d -= 2) |
| 358 | { | 348 | { |
| 359 | if (v > best | 349 | OFFSET dd = d - bmid; |
| 360 | && xoff < x && x <= xlim - SNAKE_LIMIT | 350 | OFFSET x = bd[d]; |
| 361 | && yoff < y && y <= ylim - SNAKE_LIMIT) | 351 | OFFSET y = x - d; |
| 352 | OFFSET v = (xlim - x) * 2 + dd; | ||
| 353 | |||
| 354 | if (v > 12 * (c + (dd < 0 ? -dd : dd))) | ||
| 362 | { | 355 | { |
| 363 | /* We have a good enough best diagonal; now insist | 356 | if (v > best |
| 364 | that it end with a significant snake. */ | 357 | && xoff < x && x <= xlim - SNAKE_LIMIT |
| 365 | int k; | 358 | && yoff < y && y <= ylim - SNAKE_LIMIT) |
| 366 | 359 | { | |
| 367 | for (k = 0; XREF_YREF_EQUAL (x + k, y + k); k++) | 360 | /* We have a good enough best diagonal; now insist |
| 368 | if (k == SNAKE_LIMIT - 1) | 361 | that it end with a significant snake. */ |
| 369 | { | 362 | for (int k = 0; XREF_YREF_EQUAL (x + k, y + k); k++) |
| 370 | best = v; | 363 | if (k == SNAKE_LIMIT - 1) |
| 371 | part->xmid = x; | 364 | { |
| 372 | part->ymid = y; | 365 | best = v; |
| 373 | break; | 366 | part->xmid = x; |
| 374 | } | 367 | part->ymid = y; |
| 368 | break; | ||
| 369 | } | ||
| 370 | } | ||
| 375 | } | 371 | } |
| 376 | } | 372 | } |
| 373 | if (best > 0) | ||
| 374 | { | ||
| 375 | part->lo_minimal = false; | ||
| 376 | part->hi_minimal = true; | ||
| 377 | return; | ||
| 378 | } | ||
| 377 | } | 379 | } |
| 378 | if (best > 0) | 380 | } |
| 379 | { | ||
| 380 | part->lo_minimal = false; | ||
| 381 | part->hi_minimal = true; | ||
| 382 | return; | ||
| 383 | } | ||
| 384 | } | ||
| 385 | } | ||
| 386 | 381 | ||
| 387 | /* Heuristic: if we've gone well beyond the call of duty, give up | 382 | /* Heuristic: if we've gone well beyond the call of duty, give up |
| 388 | and report halfway between our best results so far. */ | 383 | and report halfway between our best results so far. */ |
| 389 | if (c >= ctxt->too_expensive) | 384 | if (c >= ctxt->too_expensive) |
| 390 | { | ||
| 391 | /* Find forward diagonal that maximizes X + Y. */ | ||
| 392 | OFFSET fxybest = -1, fxbest; | ||
| 393 | for (d = fmax; d >= fmin; d -= 2) | ||
| 394 | { | 385 | { |
| 395 | OFFSET x = MIN (fd[d], xlim); | 386 | /* Find forward diagonal that maximizes X + Y. */ |
| 396 | OFFSET y = x - d; | 387 | OFFSET fxybest = -1, fxbest; |
| 397 | if (ylim < y) | 388 | for (d = fmax; d >= fmin; d -= 2) |
| 398 | { | 389 | { |
| 399 | x = ylim + d; | 390 | OFFSET x = MIN (fd[d], xlim); |
| 400 | y = ylim; | 391 | OFFSET y = x - d; |
| 392 | if (ylim < y) | ||
| 393 | { | ||
| 394 | x = ylim + d; | ||
| 395 | y = ylim; | ||
| 396 | } | ||
| 397 | if (fxybest < x + y) | ||
| 398 | { | ||
| 399 | fxybest = x + y; | ||
| 400 | fxbest = x; | ||
| 401 | } | ||
| 401 | } | 402 | } |
| 402 | if (fxybest < x + y) | 403 | |
| 404 | /* Find backward diagonal that minimizes X + Y. */ | ||
| 405 | OFFSET bxybest = OFFSET_MAX, bxbest; | ||
| 406 | for (d = bmax; d >= bmin; d -= 2) | ||
| 403 | { | 407 | { |
| 404 | fxybest = x + y; | 408 | OFFSET x = MAX (xoff, bd[d]); |
| 405 | fxbest = x; | 409 | OFFSET y = x - d; |
| 410 | if (y < yoff) | ||
| 411 | { | ||
| 412 | x = yoff + d; | ||
| 413 | y = yoff; | ||
| 414 | } | ||
| 415 | if (x + y < bxybest) | ||
| 416 | { | ||
| 417 | bxybest = x + y; | ||
| 418 | bxbest = x; | ||
| 419 | } | ||
| 406 | } | 420 | } |
| 407 | } | ||
| 408 | 421 | ||
| 409 | /* Find backward diagonal that minimizes X + Y. */ | 422 | /* Use the better of the two diagonals. */ |
| 410 | OFFSET bxybest = OFFSET_MAX, bxbest; | 423 | if ((xlim + ylim) - bxybest < fxybest - (xoff + yoff)) |
| 411 | for (d = bmax; d >= bmin; d -= 2) | ||
| 412 | { | ||
| 413 | OFFSET x = MAX (xoff, bd[d]); | ||
| 414 | OFFSET y = x - d; | ||
| 415 | if (y < yoff) | ||
| 416 | { | 424 | { |
| 417 | x = yoff + d; | 425 | part->xmid = fxbest; |
| 418 | y = yoff; | 426 | part->ymid = fxybest - fxbest; |
| 427 | part->lo_minimal = true; | ||
| 428 | part->hi_minimal = false; | ||
| 419 | } | 429 | } |
| 420 | if (x + y < bxybest) | 430 | else |
| 421 | { | 431 | { |
| 422 | bxybest = x + y; | 432 | part->xmid = bxbest; |
| 423 | bxbest = x; | 433 | part->ymid = bxybest - bxbest; |
| 434 | part->lo_minimal = false; | ||
| 435 | part->hi_minimal = true; | ||
| 424 | } | 436 | } |
| 437 | return; | ||
| 425 | } | 438 | } |
| 426 | |||
| 427 | /* Use the better of the two diagonals. */ | ||
| 428 | if ((xlim + ylim) - bxybest < fxybest - (xoff + yoff)) | ||
| 429 | { | ||
| 430 | part->xmid = fxbest; | ||
| 431 | part->ymid = fxybest - fxbest; | ||
| 432 | part->lo_minimal = true; | ||
| 433 | part->hi_minimal = false; | ||
| 434 | } | ||
| 435 | else | ||
| 436 | { | ||
| 437 | part->xmid = bxbest; | ||
| 438 | part->ymid = bxybest - bxbest; | ||
| 439 | part->lo_minimal = false; | ||
| 440 | part->hi_minimal = true; | ||
| 441 | } | ||
| 442 | return; | ||
| 443 | } | 439 | } |
| 444 | } | 440 | } |
| 445 | #undef XREF_YREF_EQUAL | 441 | #undef XREF_YREF_EQUAL |
diff --git a/lib/fcntl.c b/lib/fcntl.c index f47ebde105c..29cb4f9eb84 100644 --- a/lib/fcntl.c +++ b/lib/fcntl.c | |||
| @@ -146,9 +146,8 @@ dupfd (int oldfd, int newfd, int flags) | |||
| 146 | /* Close the previous fds that turned out to be too small. */ | 146 | /* Close the previous fds that turned out to be too small. */ |
| 147 | { | 147 | { |
| 148 | int saved_errno = errno; | 148 | int saved_errno = errno; |
| 149 | unsigned int duplicated_fd; | ||
| 150 | 149 | ||
| 151 | for (duplicated_fd = 0; | 150 | for (unsigned int duplicated_fd = 0; |
| 152 | duplicated_fd < fds_to_close_bound * CHAR_BIT; | 151 | duplicated_fd < fds_to_close_bound * CHAR_BIT; |
| 153 | duplicated_fd++) | 152 | duplicated_fd++) |
| 154 | if ((fds_to_close[duplicated_fd / CHAR_BIT] | 153 | if ((fds_to_close[duplicated_fd / CHAR_BIT] |
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h index 3fbbf4b0e4a..bcb5606b13e 100644 --- a/lib/fcntl.in.h +++ b/lib/fcntl.in.h | |||
| @@ -495,6 +495,15 @@ _GL_WARN_ON_USE (openat2, "openat2 is not portable - " | |||
| 495 | # define AT_NO_AUTOMOUNT 0 | 495 | # define AT_NO_AUTOMOUNT 0 |
| 496 | #endif | 496 | #endif |
| 497 | 497 | ||
| 498 | /* errno when openat+O_NOFOLLOW fails because the file is a symlink. */ | ||
| 499 | #if defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ | ||
| 500 | # define _GL_OPENAT_ESYMLINK EMLINK | ||
| 501 | #elif defined __NetBSD__ | ||
| 502 | # define _GL_OPENAT_ESYMLINK EFTYPE | ||
| 503 | #else | ||
| 504 | # define _GL_OPENAT_ESYMLINK ELOOP | ||
| 505 | #endif | ||
| 506 | |||
| 498 | #endif /* _@GUARD_PREFIX@_FCNTL_H */ | 507 | #endif /* _@GUARD_PREFIX@_FCNTL_H */ |
| 499 | #endif /* _@GUARD_PREFIX@_FCNTL_H */ | 508 | #endif /* _@GUARD_PREFIX@_FCNTL_H */ |
| 500 | #endif | 509 | #endif |
diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c index d2fa69a2834..b1eb1f2e8e7 100644 --- a/lib/file-has-acl.c +++ b/lib/file-has-acl.c | |||
| @@ -660,9 +660,9 @@ fdfile_has_aclinfo (MAYBE_UNUSED int fd, | |||
| 660 | (aclent_t *) malloc (alloc * sizeof (aclent_t)); | 660 | (aclent_t *) malloc (alloc * sizeof (aclent_t)); |
| 661 | if (entries == NULL) | 661 | if (entries == NULL) |
| 662 | return -1; | 662 | return -1; |
| 663 | continue; | ||
| 664 | } | 663 | } |
| 665 | break; | 664 | else |
| 665 | break; | ||
| 666 | } | 666 | } |
| 667 | if (count < 0) | 667 | if (count < 0) |
| 668 | { | 668 | { |
| @@ -732,9 +732,9 @@ fdfile_has_aclinfo (MAYBE_UNUSED int fd, | |||
| 732 | entries = malloced = (ace_t *) malloc (alloc * sizeof (ace_t)); | 732 | entries = malloced = (ace_t *) malloc (alloc * sizeof (ace_t)); |
| 733 | if (entries == NULL) | 733 | if (entries == NULL) |
| 734 | return -1; | 734 | return -1; |
| 735 | continue; | ||
| 736 | } | 735 | } |
| 737 | break; | 736 | else |
| 737 | break; | ||
| 738 | } | 738 | } |
| 739 | if (count < 0) | 739 | if (count < 0) |
| 740 | { | 740 | { |
diff --git a/lib/ftoastr.c b/lib/ftoastr.c index 2438ffe837f..03252f83d38 100644 --- a/lib/ftoastr.c +++ b/lib/ftoastr.c | |||
| @@ -124,7 +124,6 @@ FTOASTR (char *buf, size_t bufsize, int flags, int width, FLOAT x) | |||
| 124 | PROMOTED_FLOAT promoted_x = x; | 124 | PROMOTED_FLOAT promoted_x = x; |
| 125 | char format[sizeof "%-+ 0*.*Lg"]; | 125 | char format[sizeof "%-+ 0*.*Lg"]; |
| 126 | FLOAT abs_x = x < 0 ? -x : x; | 126 | FLOAT abs_x = x < 0 ? -x : x; |
| 127 | int prec; | ||
| 128 | 127 | ||
| 129 | char *p = format; | 128 | char *p = format; |
| 130 | *p++ = '%'; | 129 | *p++ = '%'; |
| @@ -142,7 +141,7 @@ FTOASTR (char *buf, size_t bufsize, int flags, int width, FLOAT x) | |||
| 142 | *p++ = flags & FTOASTR_UPPER_E ? 'G' : 'g'; | 141 | *p++ = flags & FTOASTR_UPPER_E ? 'G' : 'g'; |
| 143 | *p = '\0'; | 142 | *p = '\0'; |
| 144 | 143 | ||
| 145 | for (prec = abs_x < FLOAT_MIN ? 1 : FLOAT_DIG; ; prec++) | 144 | for (int prec = abs_x < FLOAT_MIN ? 1 : FLOAT_DIG; ; prec++) |
| 146 | { | 145 | { |
| 147 | int n = snprintf (buf, bufsize, format, width, prec, promoted_x); | 146 | int n = snprintf (buf, bufsize, format, width, prec, promoted_x); |
| 148 | if (n < 0 | 147 | if (n < 0 |
diff --git a/lib/getdtablesize.c b/lib/getdtablesize.c index b98fbb70add..396993821cd 100644 --- a/lib/getdtablesize.c +++ b/lib/getdtablesize.c | |||
| @@ -61,13 +61,10 @@ getdtablesize (void) | |||
| 61 | { | 61 | { |
| 62 | /* We are looking for the number N such that the valid file descriptors | 62 | /* We are looking for the number N such that the valid file descriptors |
| 63 | are 0..N-1. It can be obtained through a loop as follows: | 63 | are 0..N-1. It can be obtained through a loop as follows: |
| 64 | { | 64 | for (int fd = 3; fd < 65536; fd++) |
| 65 | int fd; | 65 | if (dup2 (0, fd) == -1) |
| 66 | for (fd = 3; fd < 65536; fd++) | 66 | break; |
| 67 | if (dup2 (0, fd) == -1) | 67 | return fd; |
| 68 | break; | ||
| 69 | return fd; | ||
| 70 | } | ||
| 71 | On Windows XP, the result is 2048. | 68 | On Windows XP, the result is 2048. |
| 72 | The drawback of this loop is that it allocates memory for a libc | 69 | The drawback of this loop is that it allocates memory for a libc |
| 73 | internal array that is never freed. | 70 | internal array that is never freed. |
diff --git a/lib/getloadavg.c b/lib/getloadavg.c index 1e3e215360b..f9ed97b04bd 100644 --- a/lib/getloadavg.c +++ b/lib/getloadavg.c | |||
| @@ -623,11 +623,11 @@ getloadavg (double loadavg[], int nelem) | |||
| 623 | struct proc_summary proc_sum_data; | 623 | struct proc_summary proc_sum_data; |
| 624 | struct stat_descr proc_info; | 624 | struct stat_descr proc_info; |
| 625 | double load; | 625 | double load; |
| 626 | register unsigned int i, j; | 626 | register unsigned int j; |
| 627 | 627 | ||
| 628 | if (cpus == 0) | 628 | if (cpus == 0) |
| 629 | { | 629 | { |
| 630 | register unsigned int c, i; | 630 | register unsigned int c; |
| 631 | struct cpu_config conf; | 631 | struct cpu_config conf; |
| 632 | struct stat_descr desc; | 632 | struct stat_descr desc; |
| 633 | 633 | ||
| @@ -641,7 +641,7 @@ getloadavg (double loadavg[], int nelem) | |||
| 641 | return -1; | 641 | return -1; |
| 642 | 642 | ||
| 643 | c = 0; | 643 | c = 0; |
| 644 | for (i = 0; i < conf.config_maxclass; ++i) | 644 | for (unsigned int i = 0; i < conf.config_maxclass; ++i) |
| 645 | { | 645 | { |
| 646 | struct class_stats stats; | 646 | struct class_stats stats; |
| 647 | memset (&stats, 0, sizeof stats); | 647 | memset (&stats, 0, sizeof stats); |
| @@ -672,7 +672,7 @@ getloadavg (double loadavg[], int nelem) | |||
| 672 | 672 | ||
| 673 | load = proc_sum_data.ps_nrunnable; | 673 | load = proc_sum_data.ps_nrunnable; |
| 674 | j = 0; | 674 | j = 0; |
| 675 | for (i = samples - 1; i > 0; --i) | 675 | for (unsigned int i = samples - 1; i > 0; --i) |
| 676 | { | 676 | { |
| 677 | load += proc_sum_data.ps_nrun[j]; | 677 | load += proc_sum_data.ps_nrun[j]; |
| 678 | if (j++ == PS_NRUNSIZE) | 678 | if (j++ == PS_NRUNSIZE) |
diff --git a/lib/group-member.c b/lib/group-member.c index a26eebe37d2..34938a1b05e 100644 --- a/lib/group-member.c +++ b/lib/group-member.c | |||
| @@ -73,14 +73,13 @@ get_group_info (struct group_info *gi) | |||
| 73 | int | 73 | int |
| 74 | group_member (gid_t gid) | 74 | group_member (gid_t gid) |
| 75 | { | 75 | { |
| 76 | int i; | ||
| 77 | int found; | 76 | int found; |
| 78 | struct group_info gi; | 77 | struct group_info gi; |
| 79 | int n_groups = get_group_info (&gi); | 78 | int n_groups = get_group_info (&gi); |
| 80 | 79 | ||
| 81 | /* Search through the list looking for GID. */ | 80 | /* Search through the list looking for GID. */ |
| 82 | found = 0; | 81 | found = 0; |
| 83 | for (i = 0; i < n_groups; i++) | 82 | for (int i = 0; i < n_groups; i++) |
| 84 | { | 83 | { |
| 85 | if (gid == gi.group[i]) | 84 | if (gid == gi.group[i]) |
| 86 | { | 85 | { |
| @@ -99,9 +98,7 @@ group_member (gid_t gid) | |||
| 99 | int | 98 | int |
| 100 | main (int argc, char **argv) | 99 | main (int argc, char **argv) |
| 101 | { | 100 | { |
| 102 | int i; | 101 | for (int i = 1; i < argc; i++) |
| 103 | |||
| 104 | for (i = 1; i < argc; i++) | ||
| 105 | { | 102 | { |
| 106 | gid_t gid; | 103 | gid_t gid; |
| 107 | 104 | ||
diff --git a/lib/intprops-internal.h b/lib/intprops-internal.h index 2609803094b..856cfa534f2 100644 --- a/lib/intprops-internal.h +++ b/lib/intprops-internal.h | |||
| @@ -116,8 +116,8 @@ | |||
| 116 | #endif | 116 | #endif |
| 117 | 117 | ||
| 118 | /* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */ | 118 | /* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */ |
| 119 | #if defined __clang_major__ && __clang_major__ < 14 | 119 | #if defined __clang_major__ && __clang_major__ < 21 |
| 120 | /* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */ | 120 | /* Work around Clang bug <https://github.com/llvm/llvm-project/issues/16778>. */ |
| 121 | # define _GL_HAS_BUILTIN_MUL_OVERFLOW 0 | 121 | # define _GL_HAS_BUILTIN_MUL_OVERFLOW 0 |
| 122 | #else | 122 | #else |
| 123 | # define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW | 123 | # define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW |
| @@ -179,9 +179,9 @@ | |||
| 179 | _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW) | 179 | _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW) |
| 180 | #endif | 180 | #endif |
| 181 | 181 | ||
| 182 | /* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See: | 182 | /* Nonzero if this compiler has GCC bug 68193 or Clang bug 25764. See: |
| 183 | https://gcc.gnu.org/PR68193 | 183 | https://gcc.gnu.org/PR68193 |
| 184 | https://llvm.org/bugs/show_bug.cgi?id=25390 | 184 | https://github.com/llvm/llvm-project/issues/25764 |
| 185 | For now, assume GCC < 14 and all Clang versions generate bogus | 185 | For now, assume GCC < 14 and all Clang versions generate bogus |
| 186 | warnings for _Generic. This matters only for compilers that | 186 | warnings for _Generic. This matters only for compilers that |
| 187 | lack relevant builtins. */ | 187 | lack relevant builtins. */ |
diff --git a/lib/memrchr.c b/lib/memrchr.c index b143fb0a3a5..0c4022caff1 100644 --- a/lib/memrchr.c +++ b/lib/memrchr.c | |||
| @@ -84,15 +84,11 @@ __memrchr (void const *s, int c_in, size_t n) | |||
| 84 | repeated_one |= repeated_one << 31 << 1; | 84 | repeated_one |= repeated_one << 31 << 1; |
| 85 | repeated_c |= repeated_c << 31 << 1; | 85 | repeated_c |= repeated_c << 31 << 1; |
| 86 | if (8 < sizeof (longword)) | 86 | if (8 < sizeof (longword)) |
| 87 | { | 87 | for (size_t i = 64; i < sizeof (longword) * 8; i *= 2) |
| 88 | size_t i; | 88 | { |
| 89 | 89 | repeated_one |= repeated_one << i; | |
| 90 | for (i = 64; i < sizeof (longword) * 8; i *= 2) | 90 | repeated_c |= repeated_c << i; |
| 91 | { | 91 | } |
| 92 | repeated_one |= repeated_one << i; | ||
| 93 | repeated_c |= repeated_c << i; | ||
| 94 | } | ||
| 95 | } | ||
| 96 | } | 92 | } |
| 97 | 93 | ||
| 98 | /* Instead of the traditional loop which tests each byte, we will test a | 94 | /* Instead of the traditional loop which tests each byte, we will test a |
diff --git a/lib/mktime.c b/lib/mktime.c index 4218fca69b1..90d2002f27e 100644 --- a/lib/mktime.c +++ b/lib/mktime.c | |||
| @@ -468,11 +468,9 @@ __mktime_internal (struct tm *tp, bool local, mktime_offset_t *offset) | |||
| 468 | int year_seconds_bound = 366 * 24 * 60 * 60 + 1; | 468 | int year_seconds_bound = 366 * 24 * 60 * 60 + 1; |
| 469 | int delta_bound = year_seconds_bound + stride; | 469 | int delta_bound = year_seconds_bound + stride; |
| 470 | 470 | ||
| 471 | int delta, direction; | ||
| 472 | |||
| 473 | /* Search in both directions, closest first. */ | 471 | /* Search in both directions, closest first. */ |
| 474 | for (delta = stride; delta < delta_bound; delta += stride) | 472 | for (int delta = stride; delta < delta_bound; delta += stride) |
| 475 | for (direction = -1; direction <= 1; direction += 2) | 473 | for (int direction = -1; direction <= 1; direction += 2) |
| 476 | { | 474 | { |
| 477 | long_int ot; | 475 | long_int ot; |
| 478 | if (! ckd_add (&ot, t, delta * direction)) | 476 | if (! ckd_add (&ot, t, delta * direction)) |
diff --git a/lib/nproc.c b/lib/nproc.c index 9404be1d384..1cccfc56065 100644 --- a/lib/nproc.c +++ b/lib/nproc.c | |||
| @@ -89,10 +89,8 @@ num_processors_via_affinity_mask (void) | |||
| 89 | /* glibc >= 2.6 has the CPU_COUNT macro. */ | 89 | /* glibc >= 2.6 has the CPU_COUNT macro. */ |
| 90 | count = CPU_COUNT (&set); | 90 | count = CPU_COUNT (&set); |
| 91 | # else | 91 | # else |
| 92 | size_t i; | ||
| 93 | |||
| 94 | count = 0; | 92 | count = 0; |
| 95 | for (i = 0; i < CPU_SETSIZE; i++) | 93 | for (size_t i = 0; i < CPU_SETSIZE; i++) |
| 96 | if (CPU_ISSET (i, &set)) | 94 | if (CPU_ISSET (i, &set)) |
| 97 | count++; | 95 | count++; |
| 98 | # endif | 96 | # endif |
| @@ -112,9 +110,7 @@ num_processors_via_affinity_mask (void) | |||
| 112 | if (pthread_getaffinity_np (pthread_self (), cpuset_size (set), set) | 110 | if (pthread_getaffinity_np (pthread_self (), cpuset_size (set), set) |
| 113 | == 0) | 111 | == 0) |
| 114 | { | 112 | { |
| 115 | cpuid_t i; | 113 | for (cpuid_t i = 0;; i++) |
| 116 | |||
| 117 | for (i = 0;; i++) | ||
| 118 | { | 114 | { |
| 119 | int ret = cpuset_isset (i, set); | 115 | int ret = cpuset_isset (i, set); |
| 120 | if (ret < 0) | 116 | if (ret < 0) |
| @@ -180,10 +176,8 @@ num_processors_via_affinity_mask (void) | |||
| 180 | /* glibc >= 2.6 has the CPU_COUNT macro. */ | 176 | /* glibc >= 2.6 has the CPU_COUNT macro. */ |
| 181 | count = CPU_COUNT (&set); | 177 | count = CPU_COUNT (&set); |
| 182 | # else | 178 | # else |
| 183 | size_t i; | ||
| 184 | |||
| 185 | count = 0; | 179 | count = 0; |
| 186 | for (i = 0; i < CPU_SETSIZE; i++) | 180 | for (size_t i = 0; i < CPU_SETSIZE; i++) |
| 187 | if (CPU_ISSET (i, &set)) | 181 | if (CPU_ISSET (i, &set)) |
| 188 | count++; | 182 | count++; |
| 189 | # endif | 183 | # endif |
| @@ -202,9 +196,7 @@ num_processors_via_affinity_mask (void) | |||
| 202 | 196 | ||
| 203 | if (sched_getaffinity_np (getpid (), cpuset_size (set), set) == 0) | 197 | if (sched_getaffinity_np (getpid (), cpuset_size (set), set) == 0) |
| 204 | { | 198 | { |
| 205 | cpuid_t i; | 199 | for (cpuid_t i = 0;; i++) |
| 206 | |||
| 207 | for (i = 0;; i++) | ||
| 208 | { | 200 | { |
| 209 | int ret = cpuset_isset (i, set); | 201 | int ret = cpuset_isset (i, set); |
| 210 | if (ret < 0) | 202 | if (ret < 0) |
diff --git a/lib/pselect.c b/lib/pselect.c index 78f0446fee9..f6599f5f23b 100644 --- a/lib/pselect.c +++ b/lib/pselect.c | |||
| @@ -95,15 +95,13 @@ rpl_pselect (int nfds, fd_set *restrict rfds, | |||
| 95 | struct timespec const *restrict timeout, | 95 | struct timespec const *restrict timeout, |
| 96 | sigset_t const *restrict sigmask) | 96 | sigset_t const *restrict sigmask) |
| 97 | { | 97 | { |
| 98 | int i; | ||
| 99 | |||
| 100 | /* FreeBSD 8.2 has a bug: it does not always detect invalid fds. */ | 98 | /* FreeBSD 8.2 has a bug: it does not always detect invalid fds. */ |
| 101 | if (nfds < 0 || nfds > FD_SETSIZE) | 99 | if (nfds < 0 || nfds > FD_SETSIZE) |
| 102 | { | 100 | { |
| 103 | errno = EINVAL; | 101 | errno = EINVAL; |
| 104 | return -1; | 102 | return -1; |
| 105 | } | 103 | } |
| 106 | for (i = 0; i < nfds; i++) | 104 | for (int i = 0; i < nfds; i++) |
| 107 | { | 105 | { |
| 108 | if (((rfds && FD_ISSET (i, rfds)) | 106 | if (((rfds && FD_ISSET (i, rfds)) |
| 109 | || (wfds && FD_ISSET (i, wfds)) | 107 | || (wfds && FD_ISSET (i, wfds)) |
diff --git a/lib/set-permissions.c b/lib/set-permissions.c index af0b5de228d..27f41fde514 100644 --- a/lib/set-permissions.c +++ b/lib/set-permissions.c | |||
| @@ -99,19 +99,17 @@ set_acls_from_mode (const char *name, int desc, mode_t mode, bool *must_chmod) | |||
| 99 | errno = ENOMEM; | 99 | errno = ENOMEM; |
| 100 | return -1; | 100 | return -1; |
| 101 | } | 101 | } |
| 102 | continue; | ||
| 103 | } | 102 | } |
| 104 | break; | 103 | else |
| 104 | break; | ||
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | if (count <= 0) | 107 | if (count <= 0) |
| 108 | convention = -1; | 108 | convention = -1; |
| 109 | else | 109 | else |
| 110 | { | 110 | { |
| 111 | int i; | ||
| 112 | |||
| 113 | convention = 0; | 111 | convention = 0; |
| 114 | for (i = 0; i < count; i++) | 112 | for (int i = 0; i < count; i++) |
| 115 | if (entries[i].a_flags & (OLD_ACE_OWNER | OLD_ACE_GROUP | OLD_ACE_OTHER)) | 113 | if (entries[i].a_flags & (OLD_ACE_OWNER | OLD_ACE_GROUP | OLD_ACE_OTHER)) |
| 116 | { | 114 | { |
| 117 | convention = 1; | 115 | convention = 1; |
diff --git a/lib/sha1.c b/lib/sha1.c index d10c159af6c..fd72199d2fc 100644 --- a/lib/sha1.c +++ b/lib/sha1.c | |||
| @@ -254,8 +254,7 @@ sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx) | |||
| 254 | while (words < endp) | 254 | while (words < endp) |
| 255 | { | 255 | { |
| 256 | uint32_t tm; | 256 | uint32_t tm; |
| 257 | int t; | 257 | for (int t = 0; t < 16; t++) |
| 258 | for (t = 0; t < 16; t++) | ||
| 259 | { | 258 | { |
| 260 | x[t] = SWAP (*words); | 259 | x[t] = SWAP (*words); |
| 261 | words++; | 260 | words++; |
diff --git a/lib/sha256.c b/lib/sha256.c index 9358faff3e1..27c4f0c76f3 100644 --- a/lib/sha256.c +++ b/lib/sha256.c | |||
| @@ -96,10 +96,9 @@ set_uint32 (char *cp, uint32_t v) | |||
| 96 | void * | 96 | void * |
| 97 | sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf) | 97 | sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf) |
| 98 | { | 98 | { |
| 99 | int i; | ||
| 100 | char *r = resbuf; | 99 | char *r = resbuf; |
| 101 | 100 | ||
| 102 | for (i = 0; i < 8; i++) | 101 | for (int i = 0; i < 8; i++) |
| 103 | set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i])); | 102 | set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i])); |
| 104 | 103 | ||
| 105 | return resbuf; | 104 | return resbuf; |
| @@ -108,10 +107,9 @@ sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf) | |||
| 108 | void * | 107 | void * |
| 109 | sha224_read_ctx (const struct sha256_ctx *ctx, void *resbuf) | 108 | sha224_read_ctx (const struct sha256_ctx *ctx, void *resbuf) |
| 110 | { | 109 | { |
| 111 | int i; | ||
| 112 | char *r = resbuf; | 110 | char *r = resbuf; |
| 113 | 111 | ||
| 114 | for (i = 0; i < 7; i++) | 112 | for (int i = 0; i < 7; i++) |
| 115 | set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i])); | 113 | set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i])); |
| 116 | 114 | ||
| 117 | return resbuf; | 115 | return resbuf; |
| @@ -338,9 +336,8 @@ sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx) | |||
| 338 | { | 336 | { |
| 339 | uint32_t tm; | 337 | uint32_t tm; |
| 340 | uint32_t t0, t1; | 338 | uint32_t t0, t1; |
| 341 | int t; | ||
| 342 | /* FIXME: see sha1.c for a better implementation. */ | 339 | /* FIXME: see sha1.c for a better implementation. */ |
| 343 | for (t = 0; t < 16; t++) | 340 | for (int t = 0; t < 16; t++) |
| 344 | { | 341 | { |
| 345 | x[t] = SWAP (*words); | 342 | x[t] = SWAP (*words); |
| 346 | words++; | 343 | words++; |
diff --git a/lib/sha512.c b/lib/sha512.c index 904a8912270..76deb731008 100644 --- a/lib/sha512.c +++ b/lib/sha512.c | |||
| @@ -96,10 +96,9 @@ set_uint64 (char *cp, u64 v) | |||
| 96 | void * | 96 | void * |
| 97 | sha512_read_ctx (const struct sha512_ctx *ctx, void *resbuf) | 97 | sha512_read_ctx (const struct sha512_ctx *ctx, void *resbuf) |
| 98 | { | 98 | { |
| 99 | int i; | ||
| 100 | char *r = resbuf; | 99 | char *r = resbuf; |
| 101 | 100 | ||
| 102 | for (i = 0; i < 8; i++) | 101 | for (int i = 0; i < 8; i++) |
| 103 | set_uint64 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i])); | 102 | set_uint64 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i])); |
| 104 | 103 | ||
| 105 | return resbuf; | 104 | return resbuf; |
| @@ -108,10 +107,9 @@ sha512_read_ctx (const struct sha512_ctx *ctx, void *resbuf) | |||
| 108 | void * | 107 | void * |
| 109 | sha384_read_ctx (const struct sha512_ctx *ctx, void *resbuf) | 108 | sha384_read_ctx (const struct sha512_ctx *ctx, void *resbuf) |
| 110 | { | 109 | { |
| 111 | int i; | ||
| 112 | char *r = resbuf; | 110 | char *r = resbuf; |
| 113 | 111 | ||
| 114 | for (i = 0; i < 6; i++) | 112 | for (int i = 0; i < 6; i++) |
| 115 | set_uint64 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i])); | 113 | set_uint64 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i])); |
| 116 | 114 | ||
| 117 | return resbuf; | 115 | return resbuf; |
| @@ -367,9 +365,8 @@ sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx) | |||
| 367 | 365 | ||
| 368 | while (words < endp) | 366 | while (words < endp) |
| 369 | { | 367 | { |
| 370 | int t; | ||
| 371 | /* FIXME: see sha1.c for a better implementation. */ | 368 | /* FIXME: see sha1.c for a better implementation. */ |
| 372 | for (t = 0; t < 16; t++) | 369 | for (int t = 0; t < 16; t++) |
| 373 | { | 370 | { |
| 374 | x[t] = SWAP (*words); | 371 | x[t] = SWAP (*words); |
| 375 | words++; | 372 | words++; |
diff --git a/lib/sig2str.c b/lib/sig2str.c index bf4d009578d..d21aac1c643 100644 --- a/lib/sig2str.c +++ b/lib/sig2str.c | |||
| @@ -286,8 +286,7 @@ str2signum (char const *signame) | |||
| 286 | } | 286 | } |
| 287 | else | 287 | else |
| 288 | { | 288 | { |
| 289 | unsigned int i; | 289 | for (unsigned int i = 0; i < NUMNAME_ENTRIES; i++) |
| 290 | for (i = 0; i < NUMNAME_ENTRIES; i++) | ||
| 291 | if (streq (numname_table[i].name, signame)) | 290 | if (streq (numname_table[i].name, signame)) |
| 292 | return numname_table[i].num; | 291 | return numname_table[i].num; |
| 293 | 292 | ||
| @@ -331,8 +330,7 @@ str2sig (char const *signame, int *signum) | |||
| 331 | int | 330 | int |
| 332 | sig2str (int signum, char *signame) | 331 | sig2str (int signum, char *signame) |
| 333 | { | 332 | { |
| 334 | unsigned int i; | 333 | for (unsigned int i = 0; i < NUMNAME_ENTRIES; i++) |
| 335 | for (i = 0; i < NUMNAME_ENTRIES; i++) | ||
| 336 | if (numname_table[i].num == signum) | 334 | if (numname_table[i].num == signum) |
| 337 | { | 335 | { |
| 338 | strcpy (signame, numname_table[i].name); | 336 | strcpy (signame, numname_table[i].name); |
diff --git a/lib/stat-time.h b/lib/stat-time.h index 38315b9f569..3fab4db6923 100644 --- a/lib/stat-time.h +++ b/lib/stat-time.h | |||
| @@ -232,8 +232,7 @@ stat_time_normalize (int result, _GL_UNUSED struct stat *st) | |||
| 232 | short int const ts_off[] = { STAT_TIMESPEC_OFFSETOF (st_atim), | 232 | short int const ts_off[] = { STAT_TIMESPEC_OFFSETOF (st_atim), |
| 233 | STAT_TIMESPEC_OFFSETOF (st_mtim), | 233 | STAT_TIMESPEC_OFFSETOF (st_mtim), |
| 234 | STAT_TIMESPEC_OFFSETOF (st_ctim) }; | 234 | STAT_TIMESPEC_OFFSETOF (st_ctim) }; |
| 235 | int i; | 235 | for (int i = 0; i < sizeof ts_off / sizeof *ts_off; i++) |
| 236 | for (i = 0; i < sizeof ts_off / sizeof *ts_off; i++) | ||
| 237 | { | 236 | { |
| 238 | struct timespec *ts = (struct timespec *) ((char *) st + ts_off[i]); | 237 | struct timespec *ts = (struct timespec *) ((char *) st + ts_off[i]); |
| 239 | long int q = ts->tv_nsec / timespec_hz; | 238 | long int q = ts->tv_nsec / timespec_hz; |
diff --git a/lib/str-two-way.h b/lib/str-two-way.h index d13fb298fd6..852e5d078f2 100644 --- a/lib/str-two-way.h +++ b/lib/str-two-way.h | |||
| @@ -329,7 +329,6 @@ static RETURN_TYPE _GL_ATTRIBUTE_PURE | |||
| 329 | two_way_long_needle (const unsigned char *haystack, size_t haystack_len, | 329 | two_way_long_needle (const unsigned char *haystack, size_t haystack_len, |
| 330 | const unsigned char *needle, size_t needle_len) | 330 | const unsigned char *needle, size_t needle_len) |
| 331 | { | 331 | { |
| 332 | size_t i; /* Index into current byte of NEEDLE. */ | ||
| 333 | size_t j; /* Index into current window of HAYSTACK. */ | 332 | size_t j; /* Index into current window of HAYSTACK. */ |
| 334 | size_t period; /* The period of the right half of needle. */ | 333 | size_t period; /* The period of the right half of needle. */ |
| 335 | size_t suffix; /* The index of the right half of needle. */ | 334 | size_t suffix; /* The index of the right half of needle. */ |
| @@ -344,9 +343,9 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len, | |||
| 344 | shift_table[c] is the distance from the last occurrence of c to | 343 | shift_table[c] is the distance from the last occurrence of c to |
| 345 | the end of NEEDLE, or NEEDLE_LEN if c is absent from the NEEDLE. | 344 | the end of NEEDLE, or NEEDLE_LEN if c is absent from the NEEDLE. |
| 346 | shift_table[NEEDLE[NEEDLE_LEN - 1]] contains the only 0. */ | 345 | shift_table[NEEDLE[NEEDLE_LEN - 1]] contains the only 0. */ |
| 347 | for (i = 0; i < 1U << CHAR_BIT; i++) | 346 | for (size_t i = 0; i < 1U << CHAR_BIT; i++) |
| 348 | shift_table[i] = needle_len; | 347 | shift_table[i] = needle_len; |
| 349 | for (i = 0; i < needle_len; i++) | 348 | for (size_t i = 0; i < needle_len; i++) |
| 350 | shift_table[CANON_ELEMENT (needle[i])] = needle_len - i - 1; | 349 | shift_table[CANON_ELEMENT (needle[i])] = needle_len - i - 1; |
| 351 | 350 | ||
| 352 | /* Perform the search. Each iteration compares the right half | 351 | /* Perform the search. Each iteration compares the right half |
| @@ -379,7 +378,7 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len, | |||
| 379 | } | 378 | } |
| 380 | /* Scan for matches in right half. The last byte has | 379 | /* Scan for matches in right half. The last byte has |
| 381 | already been matched, by virtue of the shift table. */ | 380 | already been matched, by virtue of the shift table. */ |
| 382 | i = MAX (suffix, memory); | 381 | size_t i = MAX (suffix, memory); |
| 383 | while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) | 382 | while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) |
| 384 | == CANON_ELEMENT (haystack[i + j]))) | 383 | == CANON_ELEMENT (haystack[i + j]))) |
| 385 | ++i; | 384 | ++i; |
| @@ -423,7 +422,7 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len, | |||
| 423 | } | 422 | } |
| 424 | /* Scan for matches in right half. The last byte has | 423 | /* Scan for matches in right half. The last byte has |
| 425 | already been matched, by virtue of the shift table. */ | 424 | already been matched, by virtue of the shift table. */ |
| 426 | i = suffix; | 425 | size_t i = suffix; |
| 427 | while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) | 426 | while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) |
| 428 | == CANON_ELEMENT (haystack[i + j]))) | 427 | == CANON_ELEMENT (haystack[i + j]))) |
| 429 | ++i; | 428 | ++i; |
diff --git a/lib/strftime.c b/lib/strftime.c index 6445d6e3d28..291c650b970 100644 --- a/lib/strftime.c +++ b/lib/strftime.c | |||
| @@ -181,7 +181,9 @@ enum pad_style | |||
| 181 | #if SUPPORT_NON_GREG_CALENDARS_IN_STRFTIME | 181 | #if SUPPORT_NON_GREG_CALENDARS_IN_STRFTIME |
| 182 | /* Support for non-Gregorian calendars. */ | 182 | /* Support for non-Gregorian calendars. */ |
| 183 | # include "localcharset.h" | 183 | # include "localcharset.h" |
| 184 | # include "localename.h" | 184 | # if !(defined __APPLE__ && defined __MACH__) |
| 185 | # include "localename.h" | ||
| 186 | # endif | ||
| 185 | # include "calendars.h" | 187 | # include "calendars.h" |
| 186 | # define CAL_ARGS(x,y) x, y, | 188 | # define CAL_ARGS(x,y) x, y, |
| 187 | #else | 189 | #else |
| @@ -1020,8 +1022,7 @@ underlying_strftime (timezone_t tz, char *ubuf, size_t ubufsize, | |||
| 1020 | { | 1022 | { |
| 1021 | /* The last word has length >= 3. */ | 1023 | /* The last word has length >= 3. */ |
| 1022 | bool found_letter = false; | 1024 | bool found_letter = false; |
| 1023 | const char *p; | 1025 | for (const char *p = space + 1; *p != '\0'; p++) |
| 1024 | for (p = space + 1; *p != '\0'; p++) | ||
| 1025 | if ((*p >= 'A' && *p <= 'Z') | 1026 | if ((*p >= 'A' && *p <= 'Z') |
| 1026 | || (*p >= 'a' && *p <= 'z')) | 1027 | || (*p >= 'a' && *p <= 'z')) |
| 1027 | { | 1028 | { |
| @@ -1138,9 +1139,9 @@ my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 1138 | #if SUPPORT_NON_GREG_CALENDARS_IN_STRFTIME | 1139 | #if SUPPORT_NON_GREG_CALENDARS_IN_STRFTIME |
| 1139 | /* Recognize whether to use a non-Gregorian calendar. */ | 1140 | /* Recognize whether to use a non-Gregorian calendar. */ |
| 1140 | const struct calendar *cal = NULL; | 1141 | const struct calendar *cal = NULL; |
| 1141 | struct calendar_date caldate; | ||
| 1142 | if (strcmp (locale_charset (), "UTF-8") == 0) | 1142 | if (strcmp (locale_charset (), "UTF-8") == 0) |
| 1143 | { | 1143 | { |
| 1144 | # if !(defined __APPLE__ && defined __MACH__) | ||
| 1144 | const char *loc = gl_locale_name_unsafe (LC_TIME, "LC_TIME"); | 1145 | const char *loc = gl_locale_name_unsafe (LC_TIME, "LC_TIME"); |
| 1145 | if (strlen (loc) >= 5 && !(loc[5] >= 'A' && loc[5] <= 'Z')) | 1146 | if (strlen (loc) >= 5 && !(loc[5] >= 'A' && loc[5] <= 'Z')) |
| 1146 | { | 1147 | { |
| @@ -1150,15 +1151,45 @@ my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 1150 | cal = &persian_calendar; | 1151 | cal = &persian_calendar; |
| 1151 | else if (memcmp (loc, "am_ET", 5) == 0) | 1152 | else if (memcmp (loc, "am_ET", 5) == 0) |
| 1152 | cal = ðiopian_calendar; | 1153 | cal = ðiopian_calendar; |
| 1153 | if (cal != NULL) | ||
| 1154 | { | ||
| 1155 | if (cal->from_gregorian (&caldate, | ||
| 1156 | tp->tm_year + 1900, | ||
| 1157 | tp->tm_mon, | ||
| 1158 | tp->tm_mday) < 0) | ||
| 1159 | cal = NULL; | ||
| 1160 | } | ||
| 1161 | } | 1154 | } |
| 1155 | # else /* defined __APPLE__ && defined __MACH__ */ | ||
| 1156 | /* Nearly equivalent code for macOS, that avoids the need to link with | ||
| 1157 | CoreFoundation. | ||
| 1158 | It's not entirely equivalent, because it tests only for the language | ||
| 1159 | (Thai, Farsi, Amharic) instead of also for the territory (Thailand, | ||
| 1160 | Iran, Ethiopia). */ | ||
| 1161 | /* Get the translation of "Monday" in the LC_TIME locale, by calling | ||
| 1162 | the underlying strftime function. */ | ||
| 1163 | struct tm some_monday; /* 2024-01-01 12:00:00 */ | ||
| 1164 | memset (&some_monday, '\0', sizeof (struct tm)); | ||
| 1165 | some_monday.tm_year = 2024 - 1900; | ||
| 1166 | some_monday.tm_mon = 1 - 1; | ||
| 1167 | some_monday.tm_mday = 1; | ||
| 1168 | some_monday.tm_wday = 1; /* Monday */ | ||
| 1169 | some_monday.tm_hour = 12; | ||
| 1170 | some_monday.tm_min = 0; | ||
| 1171 | some_monday.tm_sec = 0; | ||
| 1172 | char weekday_buf[32]; | ||
| 1173 | if (strftime (weekday_buf, sizeof (weekday_buf), "%A", &some_monday) > 0) | ||
| 1174 | { | ||
| 1175 | /* Test for the Thai / Farsi / Amharic translation of "Monday". */ | ||
| 1176 | if (streq (weekday_buf, "จันทร์") || streq (weekday_buf, "วันจันทร์")) | ||
| 1177 | cal = &thai_calendar; | ||
| 1178 | else if (streq (weekday_buf, "ﺩﻮﺸﻨﺒﻫ") || streq (weekday_buf, "دوشنبه")) | ||
| 1179 | cal = &persian_calendar; | ||
| 1180 | else if (streq (weekday_buf, "ሰኞ")) | ||
| 1181 | cal = ðiopian_calendar; | ||
| 1182 | } | ||
| 1183 | # endif | ||
| 1184 | } | ||
| 1185 | struct calendar_date caldate; | ||
| 1186 | if (cal != NULL) | ||
| 1187 | { | ||
| 1188 | if (cal->from_gregorian (&caldate, | ||
| 1189 | tp->tm_year + 1900, | ||
| 1190 | tp->tm_mon, | ||
| 1191 | tp->tm_mday) < 0) | ||
| 1192 | cal = NULL; | ||
| 1162 | } | 1193 | } |
| 1163 | #endif | 1194 | #endif |
| 1164 | bool tzset_called = false; | 1195 | bool tzset_called = false; |
| @@ -1248,7 +1279,6 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 1248 | #endif | 1279 | #endif |
| 1249 | retval_t i = 0; | 1280 | retval_t i = 0; |
| 1250 | STREAM_OR_CHAR_T *p = s; | 1281 | STREAM_OR_CHAR_T *p = s; |
| 1251 | const CHAR_T *f; | ||
| 1252 | #if DO_MULTIBYTE && !defined COMPILE_WIDE | 1282 | #if DO_MULTIBYTE && !defined COMPILE_WIDE |
| 1253 | const char *format_end = NULL; | 1283 | const char *format_end = NULL; |
| 1254 | #endif | 1284 | #endif |
| @@ -1260,7 +1290,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 1260 | if (hour12 == 0) | 1290 | if (hour12 == 0) |
| 1261 | hour12 = 12; | 1291 | hour12 = 12; |
| 1262 | 1292 | ||
| 1263 | for (f = format; *f != '\0'; width = -1, f++) | 1293 | for (const CHAR_T *f = format; *f != '\0'; width = -1, f++) |
| 1264 | { | 1294 | { |
| 1265 | enum pad_style pad = ZERO_PAD; | 1295 | enum pad_style pad = ZERO_PAD; |
| 1266 | int modifier; /* Field modifier ('E', 'O', or 0). */ | 1296 | int modifier; /* Field modifier ('E', 'O', or 0). */ |
| @@ -1659,10 +1689,9 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 1659 | { | 1689 | { |
| 1660 | /* The last word has length >= 3. */ | 1690 | /* The last word has length >= 3. */ |
| 1661 | bool found_letter = false; | 1691 | bool found_letter = false; |
| 1662 | const char *p; | 1692 | for (const char *wp = space + 1; *wp != '\0'; wp++) |
| 1663 | for (p = space + 1; *p != '\0'; p++) | 1693 | if ((*wp >= 'A' && *wp <= 'Z') |
| 1664 | if ((*p >= 'A' && *p <= 'Z') | 1694 | || (*wp >= 'a' && *wp <= 'z')) |
| 1665 | || (*p >= 'a' && *p <= 'z')) | ||
| 1666 | { | 1695 | { |
| 1667 | found_letter = true; | 1696 | found_letter = true; |
| 1668 | break; | 1697 | break; |
diff --git a/lib/strnlen.c b/lib/strnlen.c index f6990415762..5a03d7ec942 100644 --- a/lib/strnlen.c +++ b/lib/strnlen.c | |||
| @@ -27,8 +27,7 @@ strnlen (const char *s, size_t maxlen) | |||
| 27 | { | 27 | { |
| 28 | /* Do not use memchr, because on some platforms memchr has | 28 | /* Do not use memchr, because on some platforms memchr has |
| 29 | undefined behavior if MAXLEN exceeds the number of bytes in S. */ | 29 | undefined behavior if MAXLEN exceeds the number of bytes in S. */ |
| 30 | size_t i; | 30 | for (size_t i = 0; i < maxlen && s[i]; i++) |
| 31 | for (i = 0; i < maxlen && s[i]; i++) | ||
| 32 | continue; | 31 | continue; |
| 33 | return i; | 32 | return i; |
| 34 | } | 33 | } |
diff --git a/lib/strtol.c b/lib/strtol.c index 0bcc6f40eca..954ba67a4a7 100644 --- a/lib/strtol.c +++ b/lib/strtol.c | |||
| @@ -217,7 +217,6 @@ INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr, | |||
| 217 | register unsigned int cutlim; | 217 | register unsigned int cutlim; |
| 218 | register unsigned LONG int i; | 218 | register unsigned LONG int i; |
| 219 | register const STRING_TYPE *s; | 219 | register const STRING_TYPE *s; |
| 220 | register UCHAR_TYPE c; | ||
| 221 | const STRING_TYPE *save, *end; | 220 | const STRING_TYPE *save, *end; |
| 222 | int overflow; | 221 | int overflow; |
| 223 | 222 | ||
| @@ -307,7 +306,7 @@ INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr, | |||
| 307 | { | 306 | { |
| 308 | /* Find the end of the digit string and check its grouping. */ | 307 | /* Find the end of the digit string and check its grouping. */ |
| 309 | end = s; | 308 | end = s; |
| 310 | for (c = *end; c != L_('\0'); c = *++end) | 309 | for (UCHAR_TYPE c = *end; c != L_('\0'); c = *++end) |
| 311 | if ((wchar_t) c != thousands | 310 | if ((wchar_t) c != thousands |
| 312 | && ((wchar_t) c < L_('0') || (wchar_t) c > L_('9')) | 311 | && ((wchar_t) c < L_('0') || (wchar_t) c > L_('9')) |
| 313 | && (!ISALPHA (c) || (int) (TOUPPER (c) - L_('A') + 10) >= base)) | 312 | && (!ISALPHA (c) || (int) (TOUPPER (c) - L_('A') + 10) >= base)) |
| @@ -326,7 +325,7 @@ INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr, | |||
| 326 | 325 | ||
| 327 | overflow = 0; | 326 | overflow = 0; |
| 328 | i = 0; | 327 | i = 0; |
| 329 | for (c = *s; c != L_('\0'); c = *++s) | 328 | for (UCHAR_TYPE c = *s; c != L_('\0'); c = *++s) |
| 330 | { | 329 | { |
| 331 | if (s == end) | 330 | if (s == end) |
| 332 | break; | 331 | break; |
diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h index 69c2fa9fc4e..9106702deb1 100644 --- a/lib/sys_select.in.h +++ b/lib/sys_select.in.h | |||
| @@ -152,11 +152,10 @@ typedef int suseconds_t; | |||
| 152 | static int | 152 | static int |
| 153 | rpl_fd_isset (SOCKET fd, const fd_set * set) | 153 | rpl_fd_isset (SOCKET fd, const fd_set * set) |
| 154 | { | 154 | { |
| 155 | u_int i; | ||
| 156 | if (set == NULL) | 155 | if (set == NULL) |
| 157 | return 0; | 156 | return 0; |
| 158 | 157 | ||
| 159 | for (i = 0; i < set->fd_count; i++) | 158 | for (u_int i = 0; i < set->fd_count; i++) |
| 160 | if (set->fd_array[i] == fd) | 159 | if (set->fd_array[i] == fd) |
| 161 | return 1; | 160 | return 1; |
| 162 | 161 | ||
diff --git a/lib/tempname.c b/lib/tempname.c index cd6020c0f22..cd16daf3335 100644 --- a/lib/tempname.c +++ b/lib/tempname.c | |||
| @@ -191,7 +191,6 @@ try_tempname_len (char *tmpl, int suffixlen, void *args, | |||
| 191 | { | 191 | { |
| 192 | size_t len; | 192 | size_t len; |
| 193 | char *XXXXXX; | 193 | char *XXXXXX; |
| 194 | unsigned int count; | ||
| 195 | int fd = -1; | 194 | int fd = -1; |
| 196 | int saved_errno = errno; | 195 | int saved_errno = errno; |
| 197 | 196 | ||
| @@ -236,7 +235,7 @@ try_tempname_len (char *tmpl, int suffixlen, void *args, | |||
| 236 | /* This is where the Xs start. */ | 235 | /* This is where the Xs start. */ |
| 237 | XXXXXX = &tmpl[len - x_suffix_len - suffixlen]; | 236 | XXXXXX = &tmpl[len - x_suffix_len - suffixlen]; |
| 238 | 237 | ||
| 239 | for (count = 0; count < attempts; ++count) | 238 | for (unsigned int count = 0; count < attempts; ++count) |
| 240 | { | 239 | { |
| 241 | for (size_t i = 0; i < x_suffix_len; i++) | 240 | for (size_t i = 0; i < x_suffix_len; i++) |
| 242 | { | 241 | { |