This commit is contained in:
christos 2014-09-05 21:32:37 +00:00
parent 348a9a149c
commit ae5dea0a14
7 changed files with 53 additions and 52 deletions

View File

@ -1,5 +1,5 @@
# $NetBSD: Makefile.inc,v 1.2 2011/09/16 16:41:20 joerg Exp $
# $NetBSD: Makefile.inc,v 1.3 2014/09/05 21:32:37 christos Exp $
.PATH: ${.PARSEDIR}/../dist
WARNS?= 4
CWARNFLAGS+= -Wno-missing-noreturn
WARNS?= 6
#CPPFLAGS+= -DDEBUGGING

View File

@ -1,4 +1,4 @@
/* $NetBSD: cron.c,v 1.7 2010/10/02 12:22:20 tron Exp $ */
/* $NetBSD: cron.c,v 1.8 2014/09/05 21:32:37 christos Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
@ -25,7 +25,7 @@
#if 0
static char rcsid[] = "Id: cron.c,v 1.12 2004/01/23 18:56:42 vixie Exp";
#else
__RCSID("$NetBSD: cron.c,v 1.7 2010/10/02 12:22:20 tron Exp $");
__RCSID("$NetBSD: cron.c,v 1.8 2014/09/05 21:32:37 christos Exp $");
#endif
#endif
@ -39,7 +39,7 @@ static void usage(void),
run_reboot_jobs(cron_db *),
find_jobs(time_t, cron_db *, int, int),
set_time(int),
cron_sleep(int),
cron_sleep(time_t),
sigchld_handler(int),
sighup_handler(int),
sigchld_reaper(void),
@ -131,7 +131,7 @@ main(int argc, char *argv[]) {
* clockTime: is the time when set_time was last called.
*/
for (;;) {
int timeDiff;
time_t timeDiff;
enum timejump wakeupKind;
/* ... wait for the time (in minutes) to change ... */
@ -169,8 +169,8 @@ main(int argc, char *argv[]) {
* (wokeup late) run jobs for each virtual
* minute until caught up.
*/
Debug(DSCH, ("[%ld], normal case %d minutes to go\n",
(long)getpid(), timeDiff));
Debug(DSCH, ("[%jd], normal case %jd minutes to go\n",
(intmax_t)getpid(), (intmax_t)timeDiff));
do {
if (job_runqueue())
(void)sleep(10);
@ -192,8 +192,8 @@ main(int argc, char *argv[]) {
* have a chance to run, and we do our
* housekeeping.
*/
Debug(DSCH, ("[%ld], DST begins %d minutes to go\n",
(long)getpid(), timeDiff));
Debug(DSCH, ("[%jd], DST begins %jd minutes to go\n",
(intmax_t)getpid(), (intmax_t)timeDiff));
/* run wildcard jobs for current minute */
find_jobs(timeRunning, &database, TRUE, FALSE);
@ -218,8 +218,8 @@ main(int argc, char *argv[]) {
* not be repeated. Virtual time does not
* change until we are caught up.
*/
Debug(DSCH, ("[%ld], DST ends %d minutes to go\n",
(long)getpid(), timeDiff));
Debug(DSCH, ("[%jd], DST ends %jd minutes to go\n",
(intmax_t)getpid(), (intmax_t)timeDiff));
find_jobs(timeRunning, &database, TRUE, FALSE);
break;
default:
@ -458,7 +458,7 @@ set_time(int initialize) {
* Try to just hit the next minute.
*/
static void
cron_sleep(int target) {
cron_sleep(time_t target) {
time_t t1, t2;
int seconds_to_wait;

View File

@ -1,4 +1,4 @@
/* $NetBSD: crontab.c,v 1.8 2014/09/05 20:55:11 christos Exp $ */
/* $NetBSD: crontab.c,v 1.9 2014/09/05 21:32:37 christos Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
@ -25,7 +25,7 @@
#if 0
static char rcsid[] = "Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp";
#else
__RCSID("$NetBSD: crontab.c,v 1.8 2014/09/05 20:55:11 christos Exp $");
__RCSID("$NetBSD: crontab.c,v 1.9 2014/09/05 21:32:37 christos Exp $");
#endif
#endif
@ -613,7 +613,7 @@ replace_cmd(void) {
if (fgets(n2, (int)sizeof(n2), fmaxtabsize) == NULL) {
maxtabsize = 0;
} else {
maxtabsize = atoi(n2);
maxtabsize = (size_t)atoi(n2);
}
(void)fclose(fmaxtabsize);
} else {
@ -638,7 +638,7 @@ replace_cmd(void) {
*/
(void)fprintf(tmp, "# DO NOT EDIT THIS FILE - edit the master and reinstall.\n");
(void)fprintf(tmp, "# (%s installed on %-24.24s)\n", Filename, ctime(&now));
(void)fprintf(tmp, "# (Cron version %s -- %s)\n", CRON_VERSION, "$NetBSD: crontab.c,v 1.8 2014/09/05 20:55:11 christos Exp $");
(void)fprintf(tmp, "# (Cron version %s -- %s)\n", CRON_VERSION, "$NetBSD: crontab.c,v 1.9 2014/09/05 21:32:37 christos Exp $");
/* copy the crontab to the tmp
*/
@ -646,7 +646,7 @@ replace_cmd(void) {
Set_LineNum(1);
lastch = EOF;
while (EOF != (ch = get_char(NewCrontab)))
(void)putc(lastch = ch, tmp);
(void)putc(lastch = (char)ch, tmp);
if (lastch != (char)EOF && lastch != '\n') {
warnx("missing trailing newline in `%s'", Filename);

View File

@ -1,4 +1,4 @@
/* $NetBSD: do_command.c,v 1.5 2014/06/23 01:00:48 christos Exp $ */
/* $NetBSD: do_command.c,v 1.6 2014/09/05 21:32:37 christos Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
@ -25,7 +25,7 @@
#if 0
static char rcsid[] = "Id: do_command.c,v 1.9 2004/01/23 18:56:42 vixie Exp";
#else
__RCSID("$NetBSD: do_command.c,v 1.5 2014/06/23 01:00:48 christos Exp $");
__RCSID("$NetBSD: do_command.c,v 1.6 2014/09/05 21:32:37 christos Exp $");
#endif
#endif
@ -128,7 +128,7 @@ child_process(entry *e) {
}
if (!(escaped = (ch == '\\'))) {
*p++ = ch;
*p++ = (char)ch;
}
}
if (ch == '\0') {

View File

@ -1,4 +1,4 @@
/* $NetBSD: entry.c,v 1.5 2014/06/24 09:17:54 skrll Exp $ */
/* $NetBSD: entry.c,v 1.6 2014/09/05 21:32:37 christos Exp $ */
/*
* Copyright 1988,1990,1993,1994 by Paul Vixie
@ -26,7 +26,7 @@
#if 0
static char rcsid[] = "Id: entry.c,v 1.17 2004/01/23 18:56:42 vixie Exp";
#else
__RCSID("$NetBSD: entry.c,v 1.5 2014/06/24 09:17:54 skrll Exp $");
__RCSID("$NetBSD: entry.c,v 1.6 2014/09/05 21:32:37 christos Exp $");
#endif
#endif
@ -453,7 +453,7 @@ random_with_range(int low, int high)
if (low >= high)
return low;
else
return arc4random() % (high - low + 1) + low;
return (int)arc4random() % (high - low + 1) + low;
}
static int
@ -588,7 +588,7 @@ get_number(int *numptr, int low, const char * const names[], int ch, FILE *file,
while (isdigit((unsigned char)ch)) {
if (++len >= MAX_TEMPSTR)
goto bad;
*pc++ = ch;
*pc++ = (char)ch;
ch = get_char(file);
}
*pc = '\0';
@ -605,7 +605,7 @@ get_number(int *numptr, int low, const char * const names[], int ch, FILE *file,
while (isalpha((unsigned char)ch)) {
if (++len >= MAX_TEMPSTR)
goto bad;
*pc++ = ch;
*pc++ = (char)ch;
ch = get_char(file);
}
*pc = '\0';

View File

@ -1,4 +1,4 @@
/* $NetBSD: env.c,v 1.2 2010/05/06 18:53:17 christos Exp $ */
/* $NetBSD: env.c,v 1.3 2014/09/05 21:32:37 christos Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
@ -25,7 +25,7 @@
#if 0
static char rcsid[] = "Id: env.c,v 1.10 2004/01/23 18:56:42 vixie Exp";
#else
__RCSID("$NetBSD: env.c,v 1.2 2010/05/06 18:53:17 christos Exp $");
__RCSID("$NetBSD: env.c,v 1.3 2014/09/05 21:32:37 christos Exp $");
#endif
#endif
@ -51,44 +51,45 @@ env_free(char **envp) {
char **
env_copy(char **envp) {
int count, i, save_errno;
size_t count, i;
int save_errno;
char **p;
for (count = 0; envp[count] != NULL; count++)
continue;
p = malloc((count+1) * sizeof(*p)); /* 1 for the NULL */
if (p != NULL) {
for (i = 0; i < count; i++)
if ((p[i] = strdup(envp[i])) == NULL) {
save_errno = errno;
while (--i >= 0)
free(p[i]);
free(p);
errno = save_errno;
return (NULL);
}
p[count] = NULL;
}
return (p);
p = malloc((count + 1) * sizeof(*p)); /* 1 for the NULL */
if (p != NULL)
return NULL;
for (i = 0; i < count; i++)
if ((p[i] = strdup(envp[i])) == NULL) {
save_errno = errno;
for (count = 0; count < i; count++)
free(p[count]);
free(p);
errno = save_errno;
return NULL;
}
p[count] = NULL;
return p;
}
char **
env_set(char **envp, char *envstr) {
int count, found;
size_t count, found;
char **p, *envtmp;
/*
* count the number of elements, including the null pointer;
* also set 'found' to -1 or index of entry if already in here.
*/
found = -1;
found = (size_t)-1;
for (count = 0; envp[count] != NULL; count++) {
if (!strcmp_until(envp[count], envstr, '='))
found = count;
}
count++; /* for the NULL */
if (found != -1) {
if (found != (size_t)-1) {
/*
* it exists already, so just free the existing setting,
* save our new one there, and return the existing array.
@ -107,7 +108,7 @@ env_set(char **envp, char *envstr) {
*/
if ((envtmp = strdup(envstr)) == NULL)
return (NULL);
p = realloc(envp, (size_t) ((count+1) * sizeof(*p)));
p = realloc(envp, (count + 1) * sizeof(*p));
if (p == NULL) {
free(envtmp);
return (NULL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: popen.c,v 1.3 2011/07/17 01:16:46 christos Exp $ */
/* $NetBSD: popen.c,v 1.4 2014/09/05 21:32:37 christos Exp $ */
/*
* Copyright (c) 1988, 1993, 1994
@ -44,7 +44,7 @@
static sccsid[] = "@(#)popen.c 8.3 (Berkeley) 4/6/94";
static char rcsid[] = "Id: popen.c,v 1.6 2003/02/16 04:40:01 vixie Exp";
#else
__RCSID("$NetBSD: popen.c,v 1.3 2011/07/17 01:16:46 christos Exp $");
__RCSID("$NetBSD: popen.c,v 1.4 2014/09/05 21:32:37 christos Exp $");
#endif
#endif /* not lint */
@ -59,7 +59,6 @@ __RCSID("$NetBSD: popen.c,v 1.3 2011/07/17 01:16:46 christos Exp $");
* command.
*/
static PID_T *pids;
static long fds;
FILE *
cron_popen(char *program, const char *type, struct passwd *pw) {
@ -74,9 +73,10 @@ cron_popen(char *program, const char *type, struct passwd *pw) {
if (!pids) {
size_t len;
long fds;
if ((fds = sysconf(_SC_OPEN_MAX)) <= 0)
return (NULL);
len = fds * sizeof(*pids);
len = (size_t)fds * sizeof(*pids);
if ((pids = malloc(len)) == NULL)
return (NULL);
(void)memset(pids, 0, len);