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(-Wnested-externs)
PA_ADD_CFLAGS(-Winline)
PA_ADD_CFLAGS(-Wcast-align)
PA_ADD_CFLAGS(-Wwrite-strings)
PA_ADD_CFLAGS(-pipe)
AC_CHECK_HEADERS(sysexits.h)

View file

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

View file

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

View file

@ -42,7 +42,7 @@ struct rule {
int nrule;
int rule_flags;
regex_t rx;
char *pattern;
const char *pattern;
};
/* 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() */
if ( r->pattern && *r->pattern )
free(r->pattern);
free((void *)r->pattern);
free(r);

View file

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