Skip to content

Commit

Permalink
pppd: constify log format strings. (ppp-project#462)
Browse files Browse the repository at this point in the history
Found when trying to do a simple dbglog(__FUNCTION__);

Signed-off-by: Jaco Kroon <[email protected]>
  • Loading branch information
jkroonza authored Dec 18, 2023
1 parent c975187 commit f2ef3c8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pppd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2150,7 +2150,7 @@ notify(struct notifier *notif, int val)
* novm - log an error message saying we ran out of memory, and die.
*/
void
novm(char *msg)
novm(const char *msg)
{
fatal("Virtual memory exhausted allocating %s\n", msg);
}
Expand Down
8 changes: 4 additions & 4 deletions pppd/plugins/pppoe/pppoe-discovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int pppoe_verbose;
static FILE *debugFile;

void
fatal(char *fmt, ...)
fatal(const char *fmt, ...)
{
va_list pvar;
va_start(pvar, fmt);
Expand All @@ -44,7 +44,7 @@ fatal(char *fmt, ...)
}

void
error(char *fmt, ...)
error(const char *fmt, ...)
{
va_list pvar;
va_start(pvar, fmt);
Expand All @@ -54,7 +54,7 @@ error(char *fmt, ...)
}

void
warn(char *fmt, ...)
warn(const char *fmt, ...)
{
va_list pvar;
va_start(pvar, fmt);
Expand All @@ -64,7 +64,7 @@ warn(char *fmt, ...)
}

void
info(char *fmt, ...)
info(const char *fmt, ...)
{
va_list pvar;
va_start(pvar, fmt);
Expand Down
18 changes: 9 additions & 9 deletions pppd/pppd.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ extern struct channel *the_channel;
bool debug_on();

/* Safe sprintf++ */
int slprintf(char *, int, char *, ...);
int slprintf(char *, int, const char *, ...);

/* vsprintf++ */
int vslprintf(char *, int, char *, va_list);
int vslprintf(char *, int, const char *, va_list);

/* safe strcpy */
size_t strlcpy(char *, const char *, size_t);
Expand All @@ -264,25 +264,25 @@ size_t strlcpy(char *, const char *, size_t);
size_t strlcat(char *, const char *, size_t);

/* log a debug message */
void dbglog(char *, ...);
void dbglog(const char *, ...);

/* log an informational message */
void info(char *, ...);
void info(const char *, ...);

/* log a notice-level message */
void notice(char *, ...);
void notice(const char *, ...);

/* log a warning message */
void warn(char *, ...);
void warn(const char *, ...);

/* log an error message */
void error(char *, ...);
void error(const char *, ...);

/* log an error message and die(1) */
void fatal(char *, ...);
void fatal(const char *, ...);

/* Say we ran out of memory, and die */
void novm(char *);
void novm(const char *);

/* Format a packet and log it with syslog */
void log_packet(unsigned char *, int, char *, int);
Expand Down
23 changes: 12 additions & 11 deletions pppd/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
extern char *strerror();
#endif

static void logit(int, char *, va_list);
static void logit(int, const char *, va_list);
static void log_write(int, char *);
static void vslp_printer(void *, char *, ...);
static void format_packet(u_char *, int, printer_func, void *);
Expand Down Expand Up @@ -120,7 +120,7 @@ strlcat(char *dest, const char *src, size_t len)
* Returns the number of chars put into buf.
*/
int
slprintf(char *buf, int buflen, char *fmt, ...)
slprintf(char *buf, int buflen, const char *fmt, ...)
{
va_list args;
int n;
Expand All @@ -137,14 +137,15 @@ slprintf(char *buf, int buflen, char *fmt, ...)
#define OUTCHAR(c) (buflen > 0? (--buflen, *buf++ = (c)): 0)

int
vslprintf(char *buf, int buflen, char *fmt, va_list args)
vslprintf(char *buf, int buflen, const char *fmt, va_list args)
{
int c, i, n;
int width, prec, fillch;
int base, len, neg, quoted;
long lval = 0;
unsigned long val = 0;
char *str, *f, *buf0;
char *str, *buf0;
const char *f;
unsigned char *p;
char num[32];
time_t t;
Expand Down Expand Up @@ -600,7 +601,7 @@ print_string(char *p, int len, printer_func printer, void *arg)
* logit - does the hard work for fatal et al.
*/
static void
logit(int level, char *fmt, va_list args)
logit(int level, const char *fmt, va_list args)
{
char buf[1024];

Expand Down Expand Up @@ -635,7 +636,7 @@ log_write(int level, char *buf)
* fatal - log an error message and die horribly.
*/
void
fatal(char *fmt, ...)
fatal(const char *fmt, ...)
{
va_list pvar;

Expand All @@ -655,7 +656,7 @@ fatal(char *fmt, ...)
* error - log an error message.
*/
void
error(char *fmt, ...)
error(const char *fmt, ...)
{
va_list pvar;

Expand All @@ -670,7 +671,7 @@ error(char *fmt, ...)
* warn - log a warning message.
*/
void
warn(char *fmt, ...)
warn(const char *fmt, ...)
{
va_list pvar;

Expand All @@ -684,7 +685,7 @@ warn(char *fmt, ...)
* notice - log a notice-level message.
*/
void
notice(char *fmt, ...)
notice(const char *fmt, ...)
{
va_list pvar;

Expand All @@ -698,7 +699,7 @@ notice(char *fmt, ...)
* info - log an informational message.
*/
void
info(char *fmt, ...)
info(const char *fmt, ...)
{
va_list pvar;

Expand All @@ -712,7 +713,7 @@ info(char *fmt, ...)
* dbglog - log a debug message.
*/
void
dbglog(char *fmt, ...)
dbglog(const char *fmt, ...)
{
va_list pvar;

Expand Down

0 comments on commit f2ef3c8

Please sign in to comment.