1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694
|
From: Georges Khaznadar <georgesk@debian.org>
Date: Fri, 21 Feb 2025 13:32:23 +0100
Subject: cleared warning and errors for gcc-15 compiler
---
cron.c | 20 +++++-------------
cron.h | 2 +-
crontab.c | 17 +++++----------
database.c | 30 +++++++--------------------
do_command.c | 15 ++++----------
entry.c | 68 +++++++++++++++++++++++++++++++-----------------------------
env.c | 18 +++++-----------
job.c | 4 +---
misc.c | 64 ++++++++++++++++++--------------------------------------
popen.c | 7 ++-----
user.c | 14 ++++---------
11 files changed, 90 insertions(+), 169 deletions(-)
diff --git a/cron.c b/cron.c
index 0d96b48..6de9f92 100644
--- a/cron.c
+++ b/cron.c
@@ -62,9 +62,7 @@ usage() {
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
cron_db database;
char *cs;
@@ -281,8 +279,7 @@ main(argc, argv)
static void
-run_reboot_jobs(db)
- cron_db *db;
+run_reboot_jobs(cron_db *db)
{
register user *u;
register entry *e;
@@ -317,11 +314,7 @@ run_reboot_jobs(db)
static void
-find_jobs(vtime, db, doWild, doNonWild)
- time_min vtime;
- cron_db *db;
- int doWild;
- int doNonWild;
+find_jobs(time_min vtime, cron_db *db, int doWild, int doNonWild)
{
time_t virtualSecond = vtime * SECONDS_PER_MINUTE;
register struct tm *tm = gmtime(&virtualSecond);
@@ -396,8 +389,7 @@ set_time(int initialize)
* try to just hit the next minute
*/
static void
-cron_sleep(target)
- time_min target;
+cron_sleep(time_min target)
{
time_t t;
int seconds_to_wait;
@@ -465,9 +457,7 @@ const char *getoptarg = "flL:nN";
#endif
static void
-parse_args(argc, argv)
- int argc;
- char *argv[];
+ parse_args(int argc, char *argv[])
{
int argch;
diff --git a/cron.h b/cron.h
index da31126..2b26af9 100644
--- a/cron.h
+++ b/cron.h
@@ -269,7 +269,7 @@ char *env_get __P((char *, char **)),
user *load_user __P((int, struct passwd *, char *, char *, char *)),
*find_user __P((cron_db *, const char *));
-entry *load_entry __P((FILE *, void (*)(),
+entry *load_entry __P((FILE *, void (*)(char *),
struct passwd *, char **));
FILE *cron_popen __P((char *, char *, entry *));
diff --git a/crontab.c b/crontab.c
index 4cab725..bcd89ed 100644
--- a/crontab.c
+++ b/crontab.c
@@ -79,8 +79,7 @@ static int open_tmp_crontab __P((struct stat *fsbuf));
static void cleanup_tmp_crontab __P((void));
static void
-usage(msg)
- char *msg;
+usage(char *msg)
{
if (strlen(msg) > 0)
fprintf(stderr, "%s: usage error: %s\n", ProgramName, msg);
@@ -99,9 +98,7 @@ usage(msg)
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
int exitstatus;
@@ -167,9 +164,7 @@ const char *getoptarg = "u:hnleri";
#endif
static void
-parse_args(argc, argv)
- int argc;
- char *argv[];
+parse_args(int argc, char *argv[])
{
int argch;
struct stat statbuf;
@@ -423,8 +418,7 @@ delete_cmd() {
static void
-check_error(msg)
- char *msg;
+check_error(char *msg)
{
CheckErrorCount++;
fprintf(stderr, "\"%s\":%d: %s\n", Filename, LineNumber-1, msg);
@@ -482,8 +476,7 @@ create_tmp_crontab()
just fopen() and stat()? Because there's no guarantee that you
fopen()ed the file you stat()ed.) */
static int
-open_tmp_crontab(fsbuf)
- struct stat *fsbuf;
+open_tmp_crontab(struct stat *fsbuf)
{
int t;
struct stat statbuf;
diff --git a/database.c b/database.c
index b1dc7d5..9e27ec3 100644
--- a/database.c
+++ b/database.c
@@ -57,8 +57,7 @@ static void add_orphan(const char *uname, const char *fname, const char *tabname
static void free_orphan(orphan *o);
void
-load_database(old_db)
- cron_db *old_db;
+load_database(cron_db *old_db)
{
DIR *dir;
struct stat statbuf;
@@ -257,9 +256,7 @@ load_database(old_db)
void
-link_user(db, u)
- cron_db *db;
- user *u;
+link_user(cron_db *db, user *u)
{
if (db->head == NULL)
db->head = u;
@@ -272,9 +269,7 @@ link_user(db, u)
void
-unlink_user(db, u)
- cron_db *db;
- user *u;
+unlink_user(cron_db *db, user *u)
{
if (u->prev == NULL)
db->head = u->next;
@@ -287,13 +282,10 @@ unlink_user(db, u)
u->next->prev = u->prev;
}
-
user *
-find_user(db, name)
- cron_db *db;
- const char *name;
+find_user(cron_db *db, const char *name)
{
- char *env_get();
+ char *env_get __P((char *, char **));
user *u;
for (u = db->head; u != NULL; u = u->next)
@@ -304,13 +296,8 @@ find_user(db, name)
static void
-process_crontab(uname, fname, tabname, statbuf, new_db, old_db)
- char *uname;
- char *fname;
- char *tabname;
- struct stat *statbuf;
- cron_db *new_db;
- cron_db *old_db;
+process_crontab(char *uname, char *fname, char *tabname,
+ struct stat *statbuf, cron_db *new_db, cron_db *old_db)
{
struct passwd *pw = NULL;
int crontab_fd = OK - 1;
@@ -538,8 +525,7 @@ valid_name(char *filename)
static user *
-get_next_system_crontab (curtab)
- user *curtab;
+get_next_system_crontab (user *curtab)
{
for ( ; curtab != NULL; curtab = curtab->next)
if (!strncmp(curtab->name, "*system*", 8) && curtab->name [8])
diff --git a/do_command.c b/do_command.c
index ac6e528..d3e3d86 100644
--- a/do_command.c
+++ b/do_command.c
@@ -81,9 +81,7 @@ static char **build_env(char **cronenv)
}
void
-do_command(e, u)
- entry *e;
- user *u;
+do_command(entry *e, user *u)
{
Debug(DPROC, ("[%d] do_command(%s, (%s,%d,%d))\n",
getpid(), e->cmd, u->name, e->uid, e->gid))
@@ -115,9 +113,7 @@ do_command(e, u)
void
-do_command_now(e, u)
- entry *e;
- user *u;
+do_command_now(entry *e, user *u)
{
child_process(e, u);
_exit(OK_EXIT);
@@ -133,9 +129,7 @@ do_command_now(e, u)
*/
static void
-child_process(e, u)
- entry *e;
- user *u;
+child_process(entry *e, user *u)
{
int stdin_pipe[2];
FILE *tmpout;
@@ -710,8 +704,7 @@ mail_finished:
static void
-do_univ(u)
- user *u;
+do_univ(user *u)
{
#if defined(sequent)
/* Dynix (Sequent) hack to put the user associated with
diff --git a/entry.c b/entry.c
index 8c614b1..62eb1e1 100644
--- a/entry.c
+++ b/entry.c
@@ -55,8 +55,7 @@ static char *ecodes[] =
void
-free_entry(e)
- entry *e;
+free_entry(entry *e)
{
free(e->cmd);
env_free(e->envp);
@@ -68,11 +67,8 @@ free_entry(e)
* otherwise return a pointer to a new entry.
*/
entry *
-load_entry(file, error_func, pw, envp)
- FILE *file;
- void (*error_func)();
- struct passwd *pw;
- char **envp;
+load_entry(FILE *file, void (*error_func)(char *),
+ struct passwd *pw, char **envp)
{
/* this function reads one crontab entry -- the next -- from a file.
* it skips any leading blank lines, ignores comments, and returns
@@ -370,14 +366,17 @@ load_entry(file, error_func, pw, envp)
return NULL;
}
-
+/**
+ * @param *bits one bit per flag, default=FALSE
+ * @param low bound, impl. offset for bitstr
+ * @param high bound, impl. offset for bitstr
+ * @param *names[] NULL or *[] of names for these elements
+ * @param ch current character being processed
+ * @param *file file being read
+ **/
static char
-get_list(bits, low, high, names, ch, file)
- bitstr_t *bits; /* one bit per flag, default=FALSE */
- int low, high; /* bounds, impl. offset for bitstr */
- char *names[]; /* NULL or *[] of names for these elements */
- int ch; /* current character being processed */
- FILE *file; /* file being read */
+get_list(bitstr_t *bits, int low, int high,
+ char *names[], int ch, FILE *file)
{
register int done;
@@ -418,13 +417,17 @@ get_list(bits, low, high, names, ch, file)
}
+/**
+ * @param *bits one bit per flag, default=FALSE
+ * @param low bound, impl. offset for bitstr
+ * @param high bound, impl. offset for bitstr
+ * @param *names[] NULL or names of elements
+ * @param ch current character being processed
+ * @param *file file being read
+ **/
static char
-get_range(bits, low, high, names, ch, file)
- bitstr_t *bits; /* one bit per flag, default=FALSE */
- int low, high; /* bounds, impl. offset for bitstr */
- char *names[]; /* NULL or names of elements */
- int ch; /* current character being processed */
- FILE *file; /* file being read */
+get_range(bitstr_t *bits, int low, int high,
+ char *names[], int ch, FILE *file)
{
/* range = number | number "-" number [ "/" number ]
*/
@@ -526,14 +529,15 @@ get_range(bits, low, high, names, ch, file)
return ch;
}
-
+/**
+ * @param *numptr where does the result go?
+ * @param low offset applied to result if symbolic enum used
+ * @param *names[] symbolic names, if any, for enums
+ * @param ch current character
+ * @param *file source
+ **/
static char
-get_number(numptr, low, names, ch, file)
- int *numptr; /* where does the result go? */
- int low; /* offset applied to result if symbolic enum used */
- char *names[]; /* symbolic names, if any, for enums */
- int ch; /* current character */
- FILE *file; /* source */
+get_number(int *numptr, int low, char *names[], int ch, FILE *file)
{
char temp[MAX_TEMPSTR], *pc;
int len, i, all_digits;
@@ -585,13 +589,11 @@ get_number(numptr, low, names, ch, file)
return EOF;
}
-
+/**
+ * @param *bits one bit per flag, default=FALSE
+ **/
static int
-set_element(bits, low, high, number)
- bitstr_t *bits; /* one bit per flag, default=FALSE */
- int low;
- int high;
- int number;
+set_element(bitstr_t *bits, int low, int high, int number)
{
Debug(DPARS|DEXT, ("set_element(?,%d,%d,%d)\n", low, high, number))
diff --git a/env.c b/env.c
index 3905b02..2f9be4a 100644
--- a/env.c
+++ b/env.c
@@ -35,8 +35,7 @@ env_init()
void
-env_free(envp)
- char **envp;
+env_free(char **envp)
{
char **p;
@@ -50,8 +49,7 @@ env_free(envp)
char **
-env_copy(envp)
- register char **envp;
+env_copy(register char **envp)
{
register int count, i;
register char **p;
@@ -77,9 +75,7 @@ env_copy(envp)
char **
-env_set(envp, envstr)
- char **envp;
- char *envstr;
+env_set(char **envp, char *envstr)
{
register int count, found;
register char **p;
@@ -145,9 +141,7 @@ enum env_state {
* TRUE = was an env setting
*/
int
-load_env(envstr, f)
- char *envstr;
- FILE *f;
+load_env(char *envstr, FILE *f)
{
long filepos;
int fileline;
@@ -272,9 +266,7 @@ load_env(envstr, f)
}
char *
-env_get(name, envp)
- register char *name;
- register char **envp;
+env_get(register char *name, register char **envp)
{
register int len = strlen(name);
register char *p, *q;
diff --git a/job.c b/job.c
index 941d492..029da4c 100644
--- a/job.c
+++ b/job.c
@@ -34,9 +34,7 @@ static job *jhead = NULL, *jtail = NULL;
void
-job_add(e, u)
- register entry *e;
- register user *u;
+job_add(register entry *e, register user *u)
{
register job *j;
diff --git a/misc.c b/misc.c
index 121a4d1..90b3158 100644
--- a/misc.c
+++ b/misc.c
@@ -55,10 +55,7 @@ static int LogFD = ERR;
int
-strcmp_until(left, right, until)
- char *left;
- char *right;
- int until;
+strcmp_until(char *left, char *right, int until)
{
register int diff;
@@ -81,8 +78,7 @@ strcmp_until(left, right, until)
/* strdtb(s) - delete trailing blanks in string 's' and return new length
*/
int
-strdtb(s)
- char *s;
+strdtb(char *s)
{
char *x = s;
@@ -110,8 +106,7 @@ strdtb(s)
int
-set_debug_flags(flags)
- char *flags;
+set_debug_flags(char *flags)
{
/* debug flags are of the form flag[,flag ...]
*
@@ -282,8 +277,7 @@ set_cron_cwd()
* it would be great if fflush() disassociated the file buffer.
*/
void
-acquire_daemonlock(closeflag)
- int closeflag;
+acquire_daemonlock(int closeflag)
{
static FILE *fp = NULL;
@@ -337,8 +331,7 @@ acquire_daemonlock(closeflag)
/* get_char(file) : like getc() but increment LineNumber on newlines
*/
int
-get_char(file)
- FILE *file;
+get_char(FILE *file)
{
int ch;
@@ -352,9 +345,7 @@ get_char(file)
/* unget_char(ch, file) : like ungetc but do LineNumber processing
*/
void
-unget_char(ch, file)
- int ch;
- FILE *file;
+unget_char(int ch, FILE *file)
{
ungetc(ch, file);
if (ch == '\n')
@@ -369,11 +360,7 @@ unget_char(ch, file)
* (4) returns EOF or terminating character, whichever
*/
int
-get_string(string, size, file, terms)
- char *string;
- int size;
- FILE *file;
- char *terms;
+get_string(char *string, int size, FILE *file, char *terms)
{
int ch;
@@ -394,8 +381,7 @@ get_string(string, size, file, terms)
/* skip_comments(file) : read past comment (if any)
*/
void
-skip_comments(file)
- FILE *file;
+skip_comments(FILE *file)
{
int ch;
@@ -436,9 +422,7 @@ skip_comments(file)
* FALSE otherwise.
*/
static int
-in_file(string, file)
- char *string;
- FILE *file;
+in_file(char *string, FILE* file)
{
char line[MAX_TEMPSTR];
@@ -459,8 +443,7 @@ in_file(string, file)
* or (neither file exists but user=="root" so it's okay)
*/
int
-allowed(username)
- char *username;
+allowed(char *username)
{
static int init = FALSE;
static FILE *allow, *deny;
@@ -525,11 +508,7 @@ allowed(username)
void
-log_it(username, xpid, event, detail)
- char *username;
- int xpid;
- char *event;
- char *detail;
+log_it(char *username, int xpid, char *event, char *detail)
{
PID_T pid = xpid;
#if defined(LOG_FILE)
@@ -629,14 +608,16 @@ log_close() {
}
-/* two warnings:
+/**
+ * two warnings:
* (1) this routine is fairly slow
* (2) it returns a pointer to static storage
- */
+ *
+ * @param *s string we want the first word of
+ * @param *t terminators, implicitly including \0
+ **/
char *
-first_word(s, t)
- register char *s; /* string we want the first word of */
- register char *t; /* terminators, implicitly including \0 */
+first_word(register char *s, register char *t)
{
static char retbuf[2][MAX_TEMPSTR + 1]; /* sure wish C had GC */
static int retsel = 0;
@@ -667,10 +648,7 @@ first_word(s, t)
* heavily ascii-dependent.
*/
void
-mkprint(dst, src, len)
- register char *dst;
- register unsigned char *src;
- register int len;
+mkprint(register char *dst, register unsigned char *src, register int len)
{
while (len-- > 0)
{
@@ -699,9 +677,7 @@ mkprint(dst, src, len)
* returns a pointer to malloc'd storage, you must call free yourself.
*/
char *
-mkprints(src, len)
- register unsigned char *src;
- register unsigned int len;
+mkprints(register unsigned char *src, register unsigned int len)
{
register char *dst = malloc(len*4 + 1);
diff --git a/popen.c b/popen.c
index 55fa64e..efb039f 100644
--- a/popen.c
+++ b/popen.c
@@ -48,9 +48,7 @@ static PID_T *pids;
static int fds;
FILE *
-cron_popen(program, type, e)
- char *program, *type;
- entry *e;
+cron_popen(char *program, char *type, entry *e)
{
register char *cp;
FILE *iop;
@@ -176,8 +174,7 @@ pfree:
}
int
-cron_pclose(iop)
- FILE *iop;
+cron_pclose(FILE *iop)
{
register int fdes;
sigset_t omask, mask;
diff --git a/user.c b/user.c
index f701927..4728d6c 100644
--- a/user.c
+++ b/user.c
@@ -162,8 +162,7 @@ static int get_security_context(char *name, int crontab_fd, security_context_t
static char *err_user = NULL;
void
-crontab_error(msg)
- char *msg;
+crontab_error(char *msg)
{
const char *fn;
/* Figure out the file name from the username */
@@ -180,8 +179,7 @@ crontab_error(msg)
}
void
-free_user(u)
- user *u;
+free_user(user *u)
{
entry *e, *ne;
@@ -199,12 +197,8 @@ free_user(u)
user *
-load_user(crontab_fd, pw, uname, fname, tabname)
- int crontab_fd;
- struct passwd *pw; /* NULL implies syscrontab */
- char *uname;
- char *fname;
- char *tabname;
+load_user(int crontab_fd, struct passwd *pw,
+ char *uname, char *fname, char *tabname)
{
char envstr[MAX_ENVSTR];
FILE *file;
|