summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgad <gad@FreeBSD.org>2001-07-15 00:09:46 +0000
committergad <gad@FreeBSD.org>2001-07-15 00:09:46 +0000
commit75f5203b04d78ac555161bc219da58cbfeffefbd (patch)
tree72f0a137b622cd6dc694bb199a12a08fd1b19169
parentc37f9bf14e59460fb949e607da4073e223e0972d (diff)
downloadFreeBSD-src-75f5203b04d78ac555161bc219da58cbfeffefbd.zip
FreeBSD-src-75f5203b04d78ac555161bc219da58cbfeffefbd.tar.gz
Fix most of the warnings generated by compiling lpr with -Wnon-const-format,
often by just telling gcc that some internal routine is "__printflike" (work done by Kris Kennaway <kris@FreeBSD.org>). Also fix the new warnings which show up once gcc starts checking the "printf-like parameters" passed to those routines. MFC after: 1 week
-rw-r--r--usr.sbin/lpr/common_source/displayq.c6
-rw-r--r--usr.sbin/lpr/common_source/lp.h3
-rw-r--r--usr.sbin/lpr/lpc/cmds.c10
-rw-r--r--usr.sbin/lpr/lpd/lpd.c4
-rw-r--r--usr.sbin/lpr/lpd/printjob.c5
-rw-r--r--usr.sbin/lpr/lpd/recvjob.c16
-rw-r--r--usr.sbin/lpr/lpq/lpq.c4
7 files changed, 27 insertions, 21 deletions
diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c
index 7eef91e..c4233c5 100644
--- a/usr.sbin/lpr/common_source/displayq.c
+++ b/usr.sbin/lpr/common_source/displayq.c
@@ -270,10 +270,10 @@ warn(const struct printer *pp)
void
header(void)
{
- printf(head0);
+ printf("%s", head0);
col = strlen(head0)+1;
blankfill(SIZCOL);
- printf(head1);
+ printf("%s", head1);
}
void
@@ -454,7 +454,7 @@ dump(const char *nfile, const char *datafile, int copies)
remetc = strlen(etctmpl);
etc[0] = '\0';
strncat(etc, etctmpl, remetc);
- printf(etc);
+ printf("%s", etc);
col += remetc;
rem -= remetc;
/* room for the last segment of this filename? */
diff --git a/usr.sbin/lpr/common_source/lp.h b/usr.sbin/lpr/common_source/lp.h
index 9ca0612..0adf0fd 100644
--- a/usr.sbin/lpr/common_source/lp.h
+++ b/usr.sbin/lpr/common_source/lp.h
@@ -242,7 +242,8 @@ void closeallfds(int _start);
void delay(int _millisec);
void displayq(struct printer *_pp, int _format);
void dump(const char *_nfile, const char *_datafile, int _copies);
-void fatal(const struct printer *_pp, const char *_msg, ...);
+void fatal(const struct printer *_pp, const char *_msg, ...)
+ __printflike(2, 3);
int firstprinter(struct printer *_pp, int *_error);
void free_printer(struct printer *_pp);
void free_request(struct request *_rp);
diff --git a/usr.sbin/lpr/lpc/cmds.c b/usr.sbin/lpr/lpc/cmds.c
index 8414448..bc61192 100644
--- a/usr.sbin/lpr/lpc/cmds.c
+++ b/usr.sbin/lpr/lpc/cmds.c
@@ -166,7 +166,7 @@ looperr:
case PCAPERR_SUCCESS:
break;
default:
- fatal(pp, pcaperr(cmdstatus));
+ fatal(pp, "%s", pcaperr(cmdstatus));
}
} while (more && cmdstatus);
}
@@ -182,7 +182,7 @@ looperr:
cmdstatus = getprintcap(*argv, pp);
switch (cmdstatus) {
default:
- fatal(pp, pcaperr(cmdstatus));
+ fatal(pp, "%s", pcaperr(cmdstatus));
case PCAPERR_NOTFOUND:
printf("unknown printer %s\n", *argv);
continue;
@@ -700,7 +700,7 @@ looperr:
case PCAPERR_SUCCESS:
break;
default:
- fatal(pp, pcaperr(cmdstatus));
+ fatal(pp, "%s", pcaperr(cmdstatus));
}
} while (more && cmdstatus);
}
@@ -710,7 +710,7 @@ looperr:
cmdstatus = getprintcap(argv[1], pp);
switch (cmdstatus) {
default:
- fatal(pp, pcaperr(cmdstatus));
+ fatal(pp, "%s", pcaperr(cmdstatus));
case PCAPERR_NOTFOUND:
printf("unknown printer %s\n", argv[1]);
return;
@@ -974,7 +974,7 @@ topq(int argc, char *argv[])
cmdstatus = getprintcap(*argv, pp);
switch(cmdstatus) {
default:
- fatal(pp, pcaperr(cmdstatus));
+ fatal(pp, "%s", pcaperr(cmdstatus));
case PCAPERR_NOTFOUND:
printf("unknown printer %s\n", *argv);
return;
diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c
index 866ab43..b48cf25 100644
--- a/usr.sbin/lpr/lpd/lpd.c
+++ b/usr.sbin/lpr/lpd/lpd.c
@@ -115,7 +115,7 @@ static void startup(void);
static void chkhost(struct sockaddr *_f, int _ch_opts);
static int ckqueue(struct printer *_pp);
static void fhosterr(int _dosys, const char *_sysmsg, const char *_usermsg,
- ...);
+ ...) __printf0like(3, 4);
static int *socksetup(int _af, int _debuglvl);
static void usage(void);
@@ -512,7 +512,7 @@ doit(void)
}
status = getprintcap(printer, pp);
if (status < 0)
- fatal(pp, pcaperr(status));
+ fatal(pp, "%s", pcaperr(status));
displayq(pp, cbuf[0] == CMD_SHOWQ_LONG);
exit(0);
case CMD_RMJOB: /* remove a job from the queue */
diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c
index d2705c3..e2ce3ea 100644
--- a/usr.sbin/lpr/lpd/printjob.c
+++ b/usr.sbin/lpr/lpd/printjob.c
@@ -133,7 +133,8 @@ static void opentty(const struct printer *_pp);
static void openrem(const struct printer *pp);
static int print(struct printer *_pp, int _format, char *_file);
static int printit(struct printer *_pp, char *_file);
-static void pstatus(const struct printer *_pp, const char *_msg, ...);
+static void pstatus(const struct printer *_pp, const char *_msg, ...)
+ __printflike(2, 3);
static char response(const struct printer *_pp);
static void scan_out(struct printer *_pp, int _scfd, char *_scsp,
int _dlm);
@@ -1605,7 +1606,7 @@ opennet(const struct printer *pp)
}
sleep(i);
}
- pstatus(pp, "sending to %s port %d", ep, port);
+ pstatus(pp, "sending to %s port %lu", ep, port);
}
/*
diff --git a/usr.sbin/lpr/lpd/recvjob.c b/usr.sbin/lpr/lpd/recvjob.c
index 99e38de..c610271 100644
--- a/usr.sbin/lpr/lpd/recvjob.c
+++ b/usr.sbin/lpr/lpd/recvjob.c
@@ -58,6 +58,7 @@ static const char rcsid[] =
#include <signal.h>
#include <fcntl.h>
#include <dirent.h>
+#include <errno.h>
#include <syslog.h>
#include <stdio.h>
#include <stdlib.h>
@@ -75,7 +76,7 @@ static const char *sp = "";
static char tfname[NAME_MAX]; /* tmp copy of cf before linking */
static int chksize(int _size);
-static void frecverr(const char *_msg, ...);
+static void frecverr(const char *_msg, ...) __printf0like(1, 2);
static int noresponse(void);
static void rcleanup(int _signo);
static int read_number(const char *_fn);
@@ -115,7 +116,8 @@ recvjob(const char *printer)
}
if (chdir(pp->spool_dir) < 0)
- frecverr("%s: %s: %m", pp->printer, pp->spool_dir);
+ frecverr("%s: chdir(%s): %s", pp->printer, pp->spool_dir,
+ strerror(errno));
if (stat(pp->lock_file, &stb) == 0) {
if (stb.st_mode & 010) {
/* queue is disabled */
@@ -123,7 +125,8 @@ recvjob(const char *printer)
exit(1);
}
} else if (stat(pp->spool_dir, &stb) < 0)
- frecverr("%s: %s: %m", pp->printer, pp->spool_dir);
+ frecverr("%s: stat(%s): %s", pp->printer, pp->spool_dir,
+ strerror(errno));
minfree = 2 * read_number("minfree"); /* scale KB to 512 blocks */
signal(SIGTERM, rcleanup);
signal(SIGPIPE, rcleanup);
@@ -204,7 +207,8 @@ readjob(struct printer *pp)
continue;
}
if (link(tfname, cp) < 0)
- frecverr("%s: %m", tfname);
+ frecverr("%s: link(%s): %s", pp->printer,
+ tfname, strerror(errno));
(void) unlink(tfname);
tfname[0] = '\0';
cfcnt++;
@@ -254,8 +258,8 @@ readfile(struct printer *pp, char *file, int size)
fd = open(file, O_CREAT|O_EXCL|O_WRONLY, FILMOD);
if (fd < 0) {
- frecverr("%s: readfile: error on open(%s): %m",
- pp->printer, file);
+ frecverr("%s: readfile: error on open(%s): %s",
+ pp->printer, file, strerror(errno));
/*NOTREACHED*/
}
ack();
diff --git a/usr.sbin/lpr/lpq/lpq.c b/usr.sbin/lpr/lpq/lpq.c
index 96f5d8e..734750d 100644
--- a/usr.sbin/lpr/lpq/lpq.c
+++ b/usr.sbin/lpr/lpq/lpq.c
@@ -152,7 +152,7 @@ looperr:
case PCAPERR_SUCCESS:
break;
default:
- fatal(pp, pcaperr(status));
+ fatal(pp, "%s", pcaperr(status));
}
} while (more && status);
}
@@ -162,7 +162,7 @@ looperr:
init_printer(pp);
status = getprintcap(printer, pp);
if (status < 0)
- fatal(pp, pcaperr(status));
+ fatal(pp, "%s", pcaperr(status));
displayq(pp, lflag);
}
OpenPOWER on IntegriCloud