Support "constipation" -- compile cleanly with -Wwrite-strings

This commit is contained in:
hpa 2001-08-10 18:25:08 +00:00
parent 9b5b8c5640
commit 5b0cb11445
5 changed files with 62 additions and 46 deletions

View file

@ -19,7 +19,7 @@ PA_ADD_CFLAGS(-Wmissing-prototypes)
PA_ADD_CFLAGS(-Wmissing-declarations) PA_ADD_CFLAGS(-Wmissing-declarations)
PA_ADD_CFLAGS(-Wnested-externs) PA_ADD_CFLAGS(-Wnested-externs)
PA_ADD_CFLAGS(-Winline) PA_ADD_CFLAGS(-Winline)
PA_ADD_CFLAGS(-Wcast-align) PA_ADD_CFLAGS(-Wwrite-strings)
PA_ADD_CFLAGS(-pipe) PA_ADD_CFLAGS(-pipe)
AC_CHECK_HEADERS(sysexits.h) AC_CHECK_HEADERS(sysexits.h)

View file

@ -89,7 +89,7 @@ char mode[32];
char line[LBUFLEN]; char line[LBUFLEN];
int margc; int margc;
char *margv[20]; char *margv[20];
char *prompt = "tftp"; const char *prompt = "tftp";
sigjmp_buf toplevel; sigjmp_buf toplevel;
void intr(int); void intr(int);
struct servent *sp; struct servent *sp;
@ -113,45 +113,60 @@ static void command (void);
static void getusage (char *); static void getusage (char *);
static void makeargv (void); static void makeargv (void);
static void putusage (char *); static void putusage (char *);
static void settftpmode (char *); static void settftpmode (const char *);
#define HELPINDENT (sizeof("connect")) #define HELPINDENT (sizeof("connect"))
struct cmd { struct cmd {
char *name; const char *name;
char *help; const char *help;
void (*handler) (int, char **); void (*handler) (int, char **);
}; };
char vhelp[] = "toggle verbose mode";
char thelp[] = "toggle packet tracing";
char chelp[] = "connect to remote tftp";
char qhelp[] = "exit tftp";
char hhelp[] = "print help information";
char shelp[] = "send file";
char rhelp[] = "receive file";
char mhelp[] = "set file transfer mode";
char sthelp[] = "show current status";
char xhelp[] = "set per-packet retransmission timeout";
char ihelp[] = "set total retransmission timeout";
char ashelp[] = "set mode to netascii";
char bnhelp[] = "set mode to octet";
struct cmd cmdtab[] = { struct cmd cmdtab[] = {
{ "connect", chelp, setpeer }, { "connect",
{ "mode", mhelp, modecmd }, "connect to remote tftp",
{ "put", shelp, put }, setpeer },
{ "get", rhelp, get }, { "mode",
{ "quit", qhelp, quit }, "set file transfer mode",
{ "verbose", vhelp, setverbose }, modecmd },
{ "trace", thelp, settrace }, { "put",
{ "status", sthelp, status }, "send file",
{ "binary", bnhelp, setbinary }, put },
{ "ascii", ashelp, setascii }, { "get",
{ "rexmt", xhelp, setrexmt }, "receive file",
{ "timeout", ihelp, settimeout }, get },
{ "?", hhelp, help }, { "quit",
{ 0, 0, 0 } "exit tftp",
quit },
{ "verbose",
"toggle verbose mode",
setverbose },
{ "trace",
"toggle packet tracing",
settrace },
{ "status",
"show current status",
status },
{ "binary",
"set mode to octet",
setbinary },
{ "ascii",
"set mode to netascii",
setascii },
{ "rexmt",
"set per-packet transmission timeout",
setrexmt },
{ "timeout",
"set total retransmission timeout",
settimeout },
{ "?",
"print help information",
help },
{ "help",
"print help information",
help },
{ 0, 0, 0 }
}; };
struct cmd *getcmd(char *); struct cmd *getcmd(char *);
@ -242,8 +257,8 @@ setpeer(int argc, char *argv[])
} }
struct modes { struct modes {
char *m_name; const char *m_name;
char *m_mode; const char *m_mode;
} modes[] = { } modes[] = {
{ "ascii", "netascii" }, { "ascii", "netascii" },
{ "netascii", "netascii" }, { "netascii", "netascii" },
@ -258,7 +273,7 @@ void
modecmd(int argc, char *argv[]) modecmd(int argc, char *argv[])
{ {
struct modes *p; struct modes *p;
char *sep; const char *sep;
if (argc < 2) { if (argc < 2) {
printf("Using %s mode to transfer files.\n", mode); printf("Using %s mode to transfer files.\n", mode);
@ -302,7 +317,7 @@ setascii(int argc, char *argv[])
} }
static void static void
settftpmode(char *newmode) settftpmode(const char *newmode)
{ {
strcpy(mode, newmode); strcpy(mode, newmode);
if (verbose) if (verbose)
@ -615,7 +630,8 @@ command(void)
struct cmd * struct cmd *
getcmd(char *name) getcmd(char *name)
{ {
char *p, *q; const char *p;
char *q;
struct cmd *c, *found; struct cmd *c, *found;
int nmatches, longest; int nmatches, longest;

View file

@ -336,7 +336,7 @@ makerequest(int request, const char *name,
struct errmsg { struct errmsg {
int e_code; int e_code;
char *e_msg; const char *e_msg;
} errmsgs[] = { } errmsgs[] = {
{ EUNDEF, "Undefined error code" }, { EUNDEF, "Undefined error code" },
{ ENOTFOUND, "File not found" }, { ENOTFOUND, "File not found" },
@ -385,7 +385,7 @@ nak(int error)
static void static void
tpacket(const char *s, struct tftphdr *tp, int n) tpacket(const char *s, struct tftphdr *tp, int n)
{ {
static char *opcodes[] = static const char *opcodes[] =
{ "#0", "RRQ", "WRQ", "DATA", "ACK", "ERROR", "OACK" }; { "#0", "RRQ", "WRQ", "DATA", "ACK", "ERROR", "OACK" };
char *cp, *file; char *cp, *file;
u_short op = ntohs(tp->th_opcode); u_short op = ntohs(tp->th_opcode);

View file

@ -42,7 +42,7 @@ struct rule {
int nrule; int nrule;
int rule_flags; int rule_flags;
regex_t rx; regex_t rx;
char *pattern; const char *pattern;
}; };
/* Do \-substitution. Call with string == NULL to get length only. */ /* Do \-substitution. Call with string == NULL to get length only. */
@ -251,7 +251,7 @@ void freerules(struct rule *r)
/* "" patterns aren't allocated by malloc() */ /* "" patterns aren't allocated by malloc() */
if ( r->pattern && *r->pattern ) if ( r->pattern && *r->pattern )
free(r->pattern); free((void *)r->pattern);
free(r); free(r);

View file

@ -146,7 +146,7 @@ int set_tsize(char *, char **);
int set_timeout(char *, char **); int set_timeout(char *, char **);
struct options { struct options {
char *o_opt; const char *o_opt;
int (*o_fnc)(char *, char **); int (*o_fnc)(char *, char **);
} options[] = { } options[] = {
{ "blksize", set_blksize }, { "blksize", set_blksize },
@ -210,7 +210,7 @@ main(int argc, char **argv)
int c; int c;
int setrv; int setrv;
int timeout = 900; /* Default timeout */ int timeout = 900; /* Default timeout */
char *user = "nobody"; /* Default user */ const char *user = "nobody"; /* Default user */
#ifdef WITH_REGEX #ifdef WITH_REGEX
char *rewrite_file = NULL; char *rewrite_file = NULL;
#endif #endif
@ -546,7 +546,7 @@ void sendfile(struct formats *, struct tftphdr *, int);
void recvfile(struct formats *, struct tftphdr *, int); void recvfile(struct formats *, struct tftphdr *, int);
struct formats { struct formats {
char *f_mode; const char *f_mode;
char *(*f_rewrite)(char *, int); char *(*f_rewrite)(char *, int);
int (*f_validate)(char *, int, struct formats *); int (*f_validate)(char *, int, struct formats *);
void (*f_send)(struct formats *, struct tftphdr *, int); void (*f_send)(struct formats *, struct tftphdr *, int);
@ -1096,7 +1096,7 @@ recvfile(struct formats *pf, struct tftphdr *oap, int oacklen)
struct errmsg { struct errmsg {
int e_code; int e_code;
char *e_msg; const char *e_msg;
} errmsgs[] = { } errmsgs[] = {
{ EUNDEF, "Undefined error code" }, { EUNDEF, "Undefined error code" },
{ ENOTFOUND, "File not found" }, { ENOTFOUND, "File not found" },