int timestamp_fd;
int input_fd;
int output_fd;
- int mail_header_size;
+ off_t mail_header_size;
pid_t job_pid;
pid_t mailer_pid;
int drop_job;
year, month, day_of_month);
}
-static int
+static unsigned int
time_till(job_rec *jr)
/* Return the number of seconds that we have to wait until it's time
* to start job jr.
*/
{
- unsigned int tj, tn;
+ time_t tj, tn;
if (now) return 0;
tn = time(NULL);
- tj = start_sec + jr->delay * 60;
+ tj = start_sec + (time_t)jr->delay * 60;
if (tj < tn) return 0;
if (tj - tn > 3600*24)
{
jr->ident);
return 0;
}
- return tj - tn;
+ return (unsigned int)(tj - tn);
}
static void
if (gettimeofday(&tv, &tz) != 0)
explain("Can't get exact time, failure.");
- srandom(getpid()+tv.tv_usec);
+ srandom((unsigned int)(getpid() + tv.tv_usec));
if((program_name = strrchr(argv[0], '/')) == NULL)
program_name = argv[0];
#include "matchrx.h"
int
-match_rx(const char *rx, char *string, int n_sub, /* char **substrings */...)
+match_rx(const char *rx, char *string, unsigned int n_sub, /* char **substrings */...)
/* Return 1 if the regular expression "*rx" matches the string "*string",
* 0 if not, -1 on error.
* "Extended" regular expressions are used.
int match_rx(const char *rx, char *string,
- int n_sub, /* char **substrings */...);
+ unsigned int n_sub, /* char **substrings */...);
l = strtol(s, NULL, 10);
/* we use negative as error, so I am really returning unsigned int */
if (errno == ERANGE || l < 0 || l > INT_MAX) return - 1;
- return l;
+ return (int)l;
}
static char *
c = getc(tab);
if ((c == '\n' && prev != '\\') || c == EOF)
{
- if (0 != prev) obstack_1grow(&input_o, prev);
+ if (0 != prev) obstack_1grow(&input_o, (char)prev);
break;
}
- if ('\\' != prev && 0 != prev && '\n' != prev) obstack_1grow(&input_o, prev);
+ if ('\\' != prev && 0 != prev && '\n' != prev) obstack_1grow(&input_o, (char)prev);
else if ('\n' == prev) obstack_1grow(&input_o, ' ');
prev = c;
env_rec *er;
int var_len, val_len;
- var_len = strlen(env_var);
- val_len = strlen(value);
+ var_len = (int)strlen(env_var);
+ val_len = (int)strlen(value);
er = obstack_alloc(&tab_o, sizeof(env_rec));
er->assign = obstack_alloc(&tab_o, var_len + 1 + val_len + 1);
strcpy(er->assign, env_var);
job_rec *jr;
int ident_len, command_len;
- ident_len = strlen(ident);
- command_len = strlen(command);
+ ident_len = (int)strlen(ident);
+ command_len = (int)strlen(command);
jobs_read++;
period = conv2int(periods);
delay = conv2int(delays);
job_rec *jr;
int ident_len, command_len;
- ident_len = strlen(ident);
- command_len = strlen(command);
+ ident_len = (int)strlen(ident);
+ command_len = (int)strlen(command);
jobs_read++;
delay = conv2int(delays);
if (delay < 0)
job_array = obstack_finish(&tab_o);
/* sort the jobs */
- qsort(job_array, njobs, sizeof(*job_array),
+ qsort(job_array, (size_t)njobs, sizeof(*job_array),
(int (*)(const void *, const void *))execution_order);
}
/* set bit N of bitstring name */
#define bit_set(name, bit) \
- (name)[_bit_byte(bit)] |= _bit_mask(bit)
+ (name)[_bit_byte(bit)] |= (bitstr_t)_bit_mask(bit)
/* clear bit N of bitstring name */
#define bit_clear(name, bit) \
- (name)[_bit_byte(bit)] &= ~_bit_mask(bit)
+ (name)[_bit_byte(bit)] &= (bitstr_t)~_bit_mask(bit)
/* clear bits start ... stop in bitstring */
#define bit_nclear(name, start, stop) { \
register int _startbyte = _bit_byte(_start); \
register int _stopbyte = _bit_byte(_stop); \
if (_startbyte == _stopbyte) { \
- _name[_startbyte] &= ((0xff >> (8 - (_start&0x7))) | \
+ _name[_startbyte] &= (bitstr_t)((0xff >> (8 - (_start&0x7))) | \
(0xff << ((_stop&0x7) + 1))); \
} else { \
- _name[_startbyte] &= 0xff >> (8 - (_start&0x7)); \
+ _name[_startbyte] &= (bitstr_t)(0xff >> (8 - (_start&0x7))); \
while (++_startbyte < _stopbyte) \
_name[_startbyte] = 0; \
- _name[_stopbyte] &= 0xff << ((_stop&0x7) + 1); \
+ _name[_stopbyte] &= (bitstr_t)(0xff << ((_stop&0x7) + 1)); \
} \
}
register int _startbyte = _bit_byte(_start); \
register int _stopbyte = _bit_byte(_stop); \
if (_startbyte == _stopbyte) { \
- _name[_startbyte] |= ((0xff << (_start&0x7)) & \
+ _name[_startbyte] |= (bitstr_t)((0xff << (_start&0x7)) & \
(0xff >> (7 - (_stop&0x7)))); \
} else { \
- _name[_startbyte] |= 0xff << ((_start)&0x7); \
+ _name[_startbyte] |= (bitstr_t)(0xff << ((_start)&0x7)); \
while (++_startbyte < _stopbyte) \
_name[_startbyte] = 0xff; \
- _name[_stopbyte] |= 0xff >> (7 - (_stop&0x7)); \
+ _name[_stopbyte] |= (bitstr_t)(0xff >> (7 - (_stop&0x7))); \
} \
}
/* obtain a random scaling factor for RANDOM_DELAY */
if (gettimeofday(&tv, &tz) != 0)
tv.tv_usec = 0;
- srandom(pid + tv.tv_usec);
- RandomScale = random() / (double)RAND_MAX;
+ srandom((unsigned int)(pid + tv.tv_usec));
+ RandomScale = (double)random() / (double)RAND_MAX;
snprintf(buf, sizeof(buf), "RANDOM_DELAY will be scaled with factor %d%% if used.", (int)(RandomScale*100));
log_it("CRON", pid, "INFO", buf, 0);
*/
for (u = db->head; u != NULL; u = u->next) {
for (e = u->crontab; e != NULL; e = e->next) {
- time_t virtualSecond = (vtime - e->delay) * SECONDS_PER_MINUTE;
+ time_t virtualSecond = (time_t)(vtime - e->delay) * (time_t)SECONDS_PER_MINUTE;
time_t virtualGMTSecond = virtualSecond - vGMToff;
job_tz = env_get("CRON_TZ", e->envp);
maketime(job_tz, orig_tz);
GMToff = get_gmtoff(&StartTime, &tm);
Debug(DSCH, ("[%ld] GMToff=%ld\n", (long) getpid(), (long) GMToff));
}
- clockTime = (StartTime + GMToff) / (time_t) SECONDS_PER_MINUTE;
+ clockTime = (int)((StartTime + GMToff) / (time_t) SECONDS_PER_MINUTE);
}
/*
*/
int matchuser(char *user, char *list) {
char *pos;
- int l = strlen(user);
+ size_t l = strlen(user);
for (pos = list; (pos = strstr(pos, user)) != NULL; pos += l) {
if ((pos != list) && (*(pos - 1) != ','))
file_owner = (getgid() == geteuid() && getgid() == getegid()) ? ROOT_UID : pw->pw_uid;
#ifdef HAVE_FCHOWN
- if (fchown(fileno(tmp), file_owner, -1) < OK) {
+ if (fchown(fileno(tmp), file_owner, (gid_t)-1) < OK) {
perror("fchown");
fclose(tmp);
error = -2;
goto done;
}
#else
- if (chown(TempFilename, file_owner, -1) < OK) {
+ if (chown(TempFilename, file_owner, (gid_t)-1) < OK) {
perror("chown");
fclose(tmp);
error = -2;
new_db.head = new_db.tail = NULL;
new_db.ifd = old_db->ifd;
new_db.mtime = time(NULL) - 1;
- while ((retval = read(old_db->ifd, buf, sizeof (buf))) == -1 &&
+ while ((retval = (int)read(old_db->ifd, buf, sizeof (buf))) == -1 &&
errno == EINTR) ;
if (retval == 0) {
}
static int not_a_crontab(DIR_T * dp) {
- int len;
+ size_t len;
/* avoid file names beginning with ".". this is good
* because we would otherwise waste two guaranteed calls
len = strlen(dp->d_name);
- if (len >= NAME_MAX)
- return (1); /* XXX log? */
+ if (len >= NAME_MAX || len == 0)
+ return (1);
- if ((len > 0) && (dp->d_name[len - 1] == '~'))
+ if (dp->d_name[len - 1] == '~')
return (1);
if ((len > 8) && (strncmp(dp->d_name + len - 8, ".rpmsave", 8) == 0))
char *pch;
for (pch = ProgramName; *pch; pch++)
- *pch = MkUpper(*pch);
+ *pch = (char)MkUpper(*pch);
}
#endif /* CAPITALIZE_FOR_PS */
for (input_data = p = e->cmd;
(ch = *input_data) != '\0'; input_data++, p++) {
if (p != input_data)
- *p = ch;
+ *p = (char)ch;
if (escaped) {
if (ch == '%')
- *--p = ch;
+ *--p = (char)ch;
escaped = FALSE;
continue;
}
int bufidx = 0;
if (SyslogOutput) {
if (ch != '\n')
- logbuf[bufidx++] = ch;
+ logbuf[bufidx++] = (char)ch;
}
#endif
putc(ch, mail);
#if defined(SYSLOG)
if (SyslogOutput) {
- logbuf[bufidx++] = ch;
+ logbuf[bufidx++] = (char)ch;
if ((ch == '\n') || (bufidx == sizeof(logbuf)-1)) {
if (ch == '\n')
logbuf[bufidx-1] = '\0';
if (errno != 0 || val < 0 || val > 24*60) {
log_it("CRON", getpid(), "ERROR", "bad value of RANDOM_DELAY", 0);
} else {
- e->delay = val * RandomScale;
+ e->delay = (int)((double)val * RandomScale);
}
}
while (isdigit((unsigned char) ch)) {
if (++len >= MAX_TEMPSTR)
goto bad;
- *pc++ = ch;
+ *pc++ = (char)ch;
ch = get_char(file);
}
*pc = '\0';
while (isalpha((unsigned char) ch)) {
if (++len >= MAX_TEMPSTR)
goto bad;
- *pc++ = ch;
+ *pc++ = (char)ch;
ch = get_char(file);
}
*pc = '\0';
}
char **env_copy(char **envp) {
- int count, i, save_errno;
+ int save_errno;
+ size_t count, i;
char **p;
for (count = 0; envp[count] != NULL; count++) ;
}
char **env_set(char **envp, const 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.
if ((envtmp = strdup(envstr)) == NULL)
return (NULL);
p = (char **) realloc((void *) envp,
- (size_t) ((count + 1) * sizeof (char *)));
+ (count + 1) * sizeof (char *));
if (p == NULL) {
free(envtmp);
return (NULL);
}
char *env_get(const char *name, char **envp) {
- int len = strlen(name);
+ size_t len = strlen(name);
char *p, *q;
while ((p = *envp++) != NULL) {
cron_pclose(FILE *),
glue_strings(char *, size_t, const char *, const char *, char),
strcmp_until(const char *, const char *, char),
- allowed(const char * ,const char * ,const char *),
- strdtb(char *);
+ allowed(const char * ,const char * ,const char *);
-size_t strlens(const char *, ...);
+size_t strlens(const char *, ...),
+ strdtb(char *);
char *env_get(const char *, char **),
*arpadate(time_t *),
- *mkprints(unsigned char *, unsigned int),
+ *mkprints(unsigned char *, size_t),
*first_word(const char *, const char *),
**env_init(void),
**env_copy(char **),
/* strdtb(s) - delete trailing blanks in string 's' and return new length
*/
-int strdtb(char *s) {
+size_t strdtb(char *s) {
char *x = s;
/* scan forward to the null
/* the difference between the position of the null character and
* the position of the first character of the string is the length.
*/
- return (x - s);
+ return ((size_t)(x - s));
}
int set_debug_flags(const char *flags) {
sprintf(buf, "%ld\n", (long) pid);
(void) lseek(fd, (off_t) 0, SEEK_SET);
- len = strlen(buf);
- if ((num = write(fd, buf, len)) != len)
+ len = (ssize_t)strlen(buf);
+ if ((num = write(fd, buf, (size_t)len)) != len)
log_it("CRON", pid, "ERROR", "write() failed", errno);
else {
if (ftruncate(fd, num) == -1)
/* warning:
* heavily ascii-dependent.
*/
-static void mkprint(char *dst, unsigned char *src, int len) {
+static void mkprint(char *dst, unsigned char *src, size_t len) {
/*
* XXX
* We know this routine can't overflow the dst buffer because mkprints()
if (ch < ' ') { /* control character */
*dst++ = '^';
- *dst++ = ch + '@';
+ *dst++ = (char)(ch + '@');
}
else if (ch < 0177) { /* printable */
- *dst++ = ch;
+ *dst++ = (char)ch;
}
else if (ch == 0177) { /* delete/rubout */
*dst++ = '^';
/* warning:
* returns a pointer to malloc'd storage, you must call free yourself.
*/
-char *mkprints(unsigned char *src, unsigned int len) {
+char *mkprints(unsigned char *src, size_t len) {
char *dst = malloc(len * 4 + 1);
if (dst)
if (!pids) {
if ((fds = getdtablesize()) <= 0)
return (NULL);
- if (!(pids = (PID_T *) malloc((u_int) (fds * sizeof (PID_T)))))
+ if (!(pids = (PID_T *) malloc((u_int) ((size_t)fds * sizeof (PID_T)))))
return (NULL);
- memset((char *) pids, 0, fds * sizeof (PID_T));
+ memset((char *) pids, 0, (size_t)fds * sizeof (PID_T));
}
if (pipe(pdes) < 0)
return (NULL);