summaryrefslogtreecommitdiffstats
path: root/bin/date
diff options
context:
space:
mode:
Diffstat (limited to 'bin/date')
-rw-r--r--bin/date/date.c8
-rw-r--r--bin/date/netdate.c20
-rw-r--r--bin/date/vary.c13
3 files changed, 21 insertions, 20 deletions
diff --git a/bin/date/date.c b/bin/date/date.c
index 8c42f08..0cf1d1e 100644
--- a/bin/date/date.c
+++ b/bin/date/date.c
@@ -50,12 +50,13 @@ static const char rcsid[] =
#include <ctype.h>
#include <err.h>
+#include <locale.h>
+#include <libutil.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
-#include <locale.h>
#include "extern.h"
#include "vary.h"
@@ -71,15 +72,14 @@ static void setthetime(const char *, const char *, int, int);
static void badformat(void);
static void usage(void);
-int logwtmp(char *, char *, char *);
-
int
main(int argc, char *argv[])
{
struct timezone tz;
int ch, rflag;
int jflag, nflag;
- char *format, buf[1024];
+ const char *format;
+ char buf[1024];
char *endptr, *fmt;
char *tmp;
int set_timezone;
diff --git a/bin/date/netdate.c b/bin/date/netdate.c
index c8bb51a..f9866fd 100644
--- a/bin/date/netdate.c
+++ b/bin/date/netdate.c
@@ -73,10 +73,10 @@ netsettime(time_t tval)
struct timeval tout;
struct servent *sp;
struct tsp msg;
- struct sockaddr_in sin, dest, from;
+ struct sockaddr_in lsin, dest, from;
fd_set ready;
long waittime;
- int s, length, port, timed_ack, found, err;
+ int s, length, port, timed_ack, found, lerr;
char hostname[MAXHOSTNAMELEN];
if ((sp = getservbyname("timed", "udp")) == NULL) {
@@ -94,11 +94,11 @@ netsettime(time_t tval)
return (retval = 2);
}
- memset(&sin, 0, sizeof(sin));
- sin.sin_family = AF_INET;
+ memset(&lsin, 0, sizeof(lsin));
+ lsin.sin_family = AF_INET;
for (port = IPPORT_RESERVED - 1; port > IPPORT_RESERVED / 2; port--) {
- sin.sin_port = htons((u_short)port);
- if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
+ lsin.sin_port = htons((u_short)port);
+ if (bind(s, (struct sockaddr *)&lsin, sizeof(lsin)) >= 0)
break;
if (errno == EADDRINUSE)
continue;
@@ -142,11 +142,11 @@ loop:
FD_SET(s, &ready);
found = select(FD_SETSIZE, &ready, (fd_set *)0, (fd_set *)0, &tout);
- length = sizeof(err);
+ length = sizeof(lerr);
if (!getsockopt(s,
- SOL_SOCKET, SO_ERROR, (char *)&err, &length) && err) {
- if (err != ECONNREFUSED)
- warnc(err, "send (delayed error)");
+ SOL_SOCKET, SO_ERROR, (char *)&lerr, &length) && lerr) {
+ if (lerr != ECONNREFUSED)
+ warnc(lerr, "send (delayed error)");
goto bad;
}
diff --git a/bin/date/vary.c b/bin/date/vary.c
index 7ee8a4f..2e0bb88 100644
--- a/bin/date/vary.c
+++ b/bin/date/vary.c
@@ -29,6 +29,7 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
+#include <sys/cdefs.h>
#include <err.h>
#include <time.h>
#include <string.h>
@@ -37,7 +38,7 @@ static const char rcsid[] =
struct trans {
int val;
- char *str;
+ const char *str;
};
static struct trans trans_mon[] = {
@@ -203,14 +204,14 @@ adjmon(struct tm *t, char type, int val, int istext, int mk)
static int
adjday(struct tm *t, char type, int val, int mk)
{
- int mdays;
+ int lmdays;
switch (type) {
case '+':
while (val) {
- mdays = daysinmonth(t);
- if (val > mdays - t->tm_mday) {
- val -= mdays - t->tm_mday + 1;
+ lmdays = daysinmonth(t);
+ if (val > lmdays - t->tm_mday) {
+ val -= lmdays - t->tm_mday + 1;
t->tm_mday = 1;
if (!adjmon(t, '+', 1, 0, 0))
return 0;
@@ -413,7 +414,7 @@ vary_apply(const struct vary *v, struct tm *t)
char type;
char which;
char *arg;
- int len;
+ size_t len;
int val;
for (; v; v = v->next) {
OpenPOWER on IntegriCloud