mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-11 08:52:07 +01:00
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
This commit is contained in:
parent
2a57c11a3a
commit
6d39e1b726
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=79739
@ -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? */
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user