Fix even more warnings in libwww2

Now that -Wall is turned on, it's possible to remove all sort of
unused / unread variables and even fix one case of a missing
initialization.
master
Robert Clausecker 2013-03-10 01:20:17 +07:00
parent 39b76427ae
commit 62396c5250
11 changed files with 238 additions and 349 deletions

@ -624,9 +624,6 @@ PRIVATE char *compose_auth_string ARGS2(HTAAScheme, scheme,
/* for MD5 -- DXP */
char * nonce; /* Server specified integer value */
char * opaque; /* more random MD5 junk... */
BOOL stale; /* flag indicating the previous request
from the client was rejected because
the nonce value was stale */
FREE(result); /* From previous call */

@ -139,7 +139,6 @@ PRIVATE int get_physical ARGS3(
int, bong)
{
char * access=NULL; /* Name of access method */
char * physical = NULL;
char * host = NULL;
struct Proxy *GetNoProxy();
extern int useKeepAlive;
@ -181,7 +180,6 @@ PRIVATE int get_physical ARGS3(
if (!GetNoProxy(tmp_access, tmp_host)) {
char *gateway_parameter, *gateway, *proxy;
struct Proxy *proxent = NULL, *GetProxy();
extern struct Proxy *proxy_list;
char *proxyentry = NULL;
proxy_host_fix=strdup(tmp_host);

@ -50,7 +50,6 @@ void HTCompressedFileToFile (char *fnam, int compressed)
{
char *znam;
char *cmd;
int len;
cmd=NULL;
@ -177,8 +176,6 @@ void HTCompressedFileToFile (char *fnam, int compressed)
void HTCompressedHText (HText *text, int compressed, int plain)
{
char *fnam;
char *znam;
char *cmd;
FILE *fp;
int rv, size_of_data;

@ -254,7 +254,6 @@ PRIVATE int response (cmd)
int messageStarted = 0;
char *ptr;
char bytestr[256],*byteptr;
int bytes;
if (!control || control == -1)
@ -1169,12 +1168,11 @@ ARGS4 (
HTAtom *pencoding;
char *filename = HTParse(address, "", PARSE_PATH + PARSE_PUNCTUATION);
char buffer[BUFSIZ];
char buf[BUFSIZ];
char itemtype;
char itemname[BUFSIZ];
char itemsize[BUFSIZ];
char *full_ftp_name, *ptr;
int count, ret, cmpr, c, rv;
int count, ret, cmpr, c='\0', rv;
extern char *HTgeticonname(HTFormat, char *);
char *ellipsis_string=(char *)calloc(1024,sizeof(char));
#ifdef NEW_PARSE
@ -1182,7 +1180,6 @@ int nTime;
char szDate[256];
int nStringLen;
int nSpaces;
int nOldSpaces;
char szFileInfo[32];
char szMonth[32];
char szDay[16];
@ -1310,9 +1307,7 @@ char szTime[32];
}
}
if (!buffer || !*buffer) {
continue;
}
if (!*buffer) continue;
if (usingNLST==2) { /*only name*/
strcpy(itemname,buffer);
@ -1356,7 +1351,7 @@ char szTime[32];
HText_appendText (HT, "<A HREF=\"");
/* Assuming it's a relative reference... */
if (itemname && itemname[0] != '/')
if (itemname[0] != '/')
{
HText_appendText (HT, filename);
if (filename[strlen(filename)-1] != '/')
@ -1484,7 +1479,6 @@ char szTime[32];
break;
}
}
HText_appendText (HT, buffer);
#ifndef NEW_PARSE
HText_appendText (HT, "</A>\n");
@ -1495,42 +1489,22 @@ char szTime[32];
nStringLen = strlen(buffer);
nSpaces = ftpFilenameLength - nStringLen;
/*
if (itemtype != 'd') {
*/
if (nTime == 1) {
struct tm *ptr;
time_t t;
t=time(0);
ptr=localtime(&t);
sprintf(szYear,"%d",1900+ptr->tm_year);
sprintf(szDate, "%*s%9s %s %s %s %2.2s, %s", nSpaces, " ", itemsize, szFileInfo, szTime, szMonth, szDay, szYear);
}
else if (nTime == 0) {
sprintf(szDate, "%*s%9s %s %s %s %2.2s, %s", nSpaces, " ", itemsize, szFileInfo, " ", szMonth, szDay, szYear);
}
else {
/*nSpaces += strlen(itemsize); */
sprintf(szDate, "%*s %9.9s %s %s", nSpaces, " ", itemsize, szMonth, szTime);
}
/*
if (nTime == 1) {
struct tm *ptr;
time_t t;
t=time(0);
ptr=localtime(&t);
sprintf(szYear,"%d",1900+ptr->tm_year);
sprintf(szDate, "%*s%9s %s %s %s %2.2s, %s", nSpaces, " ", itemsize, szFileInfo, szTime, szMonth, szDay, szYear);
}
else if (nTime == 0) {
sprintf(szDate, "%*s%9s %s %s %s %2.2s, %s", nSpaces, " ", itemsize, szFileInfo, " ", szMonth, szDay, szYear);
}
else {
nOldSpaces = nSpaces;
nSpaces += 22;
if (nTime == 1) {
sprintf(szDate, "%*s %s %s %2.2s", nSpaces, szFileInfo, szTime, szMonth, szDay);
}
else if (nTime == 0) {
sprintf(szDate, "%*s %s %s %2.2s, %s", nSpaces, szFileInfo, "00:00", szMonth, szDay, szYear);
}
else {
sprintf(szDate, "%*s %s %s", nOldSpaces, " ", szMonth, szTime);
}
/*nSpaces += strlen(itemsize); */
sprintf(szDate, "%*s %9.9s %s %s", nSpaces, " ", itemsize, szMonth, szTime);
}
*/
if (usingNLST!=2) {
HText_appendText (HT, szDate);
@ -2070,7 +2044,7 @@ PUBLIC int HTFTPMkDir ARGS1 ( char *, name )
{
char *curpath, *path;
char command[ LINE_LENGTH+1];
int status, method = 0;
int status = 0;
HTProgress ("FTP mkdir in progress");
if(fTimerStarted) {
@ -2145,7 +2119,7 @@ PUBLIC int HTFTPMkDir ARGS1 ( char *, name )
*/
PUBLIC int HTFTPRemove ARGS1 ( char *, name )
{
char *fname, *filename, *path;
char *fname, *filename;
char command[ LINE_LENGTH+1];
int status, method = 0, didIt = 0;

@ -355,7 +355,6 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me)
if (binary_transfer)
rename_binary_file (me->fnam);
really_done:
free (me->fnam);
if (me->mime_type) {
free(me->mime_type);

@ -123,8 +123,8 @@ PUBLIC void HTSetSuffix ARGS4(
else if (strcmp(suffix, "*.*")==0) suff = &unknown_suffix;
else {
suff = (HTSuffix*) calloc(1, sizeof(HTSuffix));
if (suff == NULL) outofmem(__FILE__, "HTSetSuffix");
if (suff == NULL) outofmem(__FILE__, "HTSetSuffix");
if (!HTSuffixes) HTSuffixes = HTList_new();
HTList_addObject(HTSuffixes, suff);
@ -165,7 +165,6 @@ PRIVATE char * vms_name(WWW_CONST char * nn, WWW_CONST char * fn)
*/
static char vmsname[INFINITY]; /* returned */
char * filename = (char*)malloc(strlen(fn)+1);
char * nodename = (char*)malloc(strlen(nn)+2+1); /* Copies to hack */
char *second; /* 2nd slash */
char *last; /* last slash */
@ -215,56 +214,6 @@ PRIVATE char * vms_name(WWW_CONST char * nn, WWW_CONST char * fn)
#endif /* vms */
/* Send README file
**
** If a README file exists, then it is inserted into the document here.
*/
#ifdef GOT_READ_DIR
PRIVATE void do_readme ARGS2(HTStructured *, target, WWW_CONST char *, localname)
{
FILE * fp;
char * readme_file_name =
malloc(strlen(localname)+ 1 + strlen(HT_DIR_README_FILE) + 1);
strcpy(readme_file_name, localname);
strcat(readme_file_name, "/");
strcat(readme_file_name, HT_DIR_README_FILE);
fp = fopen(readme_file_name, "r");
if (fp) {
HTStructuredClass targetClass;
targetClass = *target->isa; /* (Can't init agregate in K&R) */
START(HTML_PRE);
for(;;){
char c = fgetc(fp);
if (c == (char)EOF) break;
switch (c) {
case '&':
case '<':
case '>':
PUTC('&');
PUTC('#');
PUTC((char)(c / 10));
PUTC((char) (c % 10));
PUTC(';');
break;
/* case '\n':
PUTC('\r');
Bug removed thanks to joe@athena.mit.edu */
default:
PUTC(c);
}
}
END(HTML_PRE);
fclose(fp);
}
}
#endif
/* Make the cache file name for a W3 document
** ------------------------------------------
** Make up a suitable name for saving the node in
@ -891,10 +840,12 @@ PUBLIC int HTLoadFile ARGS4 (
{
char * filename;
HTFormat format;
int fd = -1; /* Unix file descriptor number = INVALID */
char * nodename = 0;
char * newname=0; /* Simplified name of file */
HTAtom * encoding; /* @@ not used yet */
#ifdef vms
char * nodename;
int fd = -1; /* Unix file descriptor number = INVALID */
#endif
int compressed;
extern char *HTgeticonname(HTFormat, char *);
@ -902,7 +853,10 @@ PUBLIC int HTLoadFile ARGS4 (
*/
StrAllocCopy(newname, addr);
filename=HTParse(newname, "", PARSE_PATH|PARSE_PUNCTUATION);
nodename=HTParse(newname, "", PARSE_HOST);
#ifdef vms
nodename=
#endif
HTParse(newname, "", PARSE_HOST);
free(newname);
format = HTFileFormat(filename, &encoding, WWW_PLAINTEXT, &compressed);
@ -984,7 +938,6 @@ forget_multi:
return HTLoadError(sink, 500,
"Multiformat: directory scan failed.");
}
while (dirbuf = readdir(dp)) {
/* while there are directory entries to be read */
if (dirbuf->d_ino == 0) continue;
@ -1019,7 +972,6 @@ forget_multi:
base[0] = 0;
StrAllocCat(localname, best_dirbuf.d_name);
goto open_file;
} else { /* If not found suitable file */
free(localname);
return HTLoadError(sink, 403, /* List formats? */

@ -100,18 +100,6 @@ PRIVATE void init_acceptable NOARGS
PRIVATE WWW_CONST char hex[17] = "0123456789abcdef";
/* Decode one hex character
*/
PRIVATE char from_hex ARGS1(char, c)
{
return (c>='0')&&(c<='9') ? c-'0'
: (c>='A')&&(c<='F') ? c-'A'+10
: (c>='a')&&(c<='f') ? c-'a'+10
: 0;
}
/* Paste in an Anchor
** ------------------
@ -171,12 +159,11 @@ PRIVATE int parse_menu ARGS2 (
char ch;
char line[BIG];
char address[BIG];
char *name, *selector; /* Gopher menu fields */
char *name, *selector = NULL; /* Gopher menu fields */
char *host;
char *port;
char *p = line;
extern int interrupted_in_htgetcharacter;
WWW_CONST char *title;
#define TAB '\t'
#define HEX_ESCAPE '%'

@ -31,10 +31,8 @@ struct _HTStructured
/* Module-wide variables
*/
*/
PRIVATE int s; /* Socket for FingerHost */
PRIVATE HTStructured * target; /* The output sink */
PRIVATE HTStructuredClass targetClass; /* Copy of fn addresses */
extern int GetMailtoKludgeInfo();

@ -252,7 +252,6 @@ PRIVATE BOOL match ARGS2 (WWW_CONST char *,unknown, WWW_CONST char *,template)
*/
char *parseemail (char *str, char *name, char *em)
{
char *c, d;
char *email, *end;
/* Pull out email address */
@ -400,7 +399,6 @@ static char b64_tab[256] = {
int base64line(FILE *fp, char *buf)
{
int last_data = 0;
unsigned char *p = (unsigned char *) buf;
if(!buf || !*buf || isspace(*buf)){
@ -441,7 +439,6 @@ int base64line(FILE *fp, char *buf)
if (*p == '=') {
fputc(c1 << 2 | c2 >> 4,fp);
last_data = 1;
break;
}
@ -865,7 +862,7 @@ static char qline[LINE_LENGTH+1];
char *NNTPgetquoteline(char *art)
{
char *p;
int i,f,status ;
int i,status;
if (!initialized)
initialized = initialize();
@ -1347,7 +1344,7 @@ void news_index(char *url)
/* Returns the status of the news buttons */
void news_status(char *url, int *prevt, int *nextt, int *prev, int *next, int *follow)
{
NewsArt *art,*tmp;
NewsArt *art;
if( art = is_news_url(url) ) {
if(prevUnread(art,!newsNoThreadJumping))
@ -1435,16 +1432,16 @@ PRIVATE void read_article ARGS1 (char *, artID)
char *references=NULL; /* Hrefs for other articles */
char *newsgroups=NULL; /* Newsgroups list */
char *from=NULL,*subj=NULL,*org=NULL,*date=NULL;
char *filename;
char *filename=NULL;
char *l = line;
int f; /* ':' flag */
int decode=0; /*uudecoding...*/
FILE *fp;
FILE *fp = NULL;
char *p = line,*pp,*m;
BOOL done = NO;
NewsArt *art,*art2,*art_t, *next;
NewsArt *art,*art2,*next;
int ll;
@ -1828,7 +1825,7 @@ PRIVATE void read_article ARGS1 (char *, artID)
NextArt = next;
if (CurrentArt) {
char *tok, d, *last;
char *tok;
newsgroup_t *ng;
if (newsgroups) {
@ -1868,7 +1865,6 @@ PRIVATE void read_list NOARGS
postable, *p;
int first, last, junk, m=0, next_m=20, done=0, intr, g=0, next_g = 50, l=0, lastg=0,mark=0;
newsgroup_t *n=NULL, *nn=NULL;
extern int twirl_increment;
START (HTML_TITLE);
PUTS ("Newsgroup Listing");
@ -2111,17 +2107,15 @@ PRIVATE void XBuildArtList ARGS3(
)
{
NewsArt *art;
char *p,*aname=NULL, *author=NULL, *aref, abuf[1024+1];
BOOL done;
char *p,*aname=NULL, *aref, abuf[1024+1];
char *num,*title,*date,*msgid,*ref,*bytes,*lines,*from=NULL;
char buf[2048];
char *reference=0; /* Href for article */
int status, count, first, last; /* Response fields */
/* count is only an upper limit */
int c,i,lineinc;
int lineinc;
HTMeter(0,NULL);
@ -2250,12 +2244,11 @@ PRIVATE void BuildArtList ARGS3(
)
{
NewsArt *art;
char *p,*aname, *author, *aref, abuf[1024+1];
BOOL done;
char *p,*aname, *aref, abuf[1024+1];
char buffer[LINE_LENGTH];
char line[LINE_LENGTH];
char *reference=0; /* Href for article */
int artno; /* Article number WITHIN GROUP */
int status, count, first, last; /* Response fields */
/* count is only an upper limit */
@ -2266,6 +2259,7 @@ PRIVATE void BuildArtList ARGS3(
if(www2Trace) fprintf(stderr,"[%s]",response_text);
#endif
sscanf(response_text, "%d %d %d %d", &status, &count, &first, &last);
#ifndef DISABLE_TRACE
if(www2Trace) fprintf(stderr,"Newsgroup status=%d, count=%d, (%d-%d)",
status, count, first, last);
@ -2475,17 +2469,10 @@ PRIVATE void read_group ARGS3(
)
{
NewsArt *art,*art2, *f;
char *p;
BOOL done;
char buffer[LINE_LENGTH], subj[LINE_LENGTH];
char line[LINE_LENGTH], from[LINE_LENGTH];
char from[LINE_LENGTH];
char efrom[LINE_LENGTH], esubj[LINE_LENGTH];
char *reference=0;
int i,artno, mark=0;
int tc=0;
int status, count; /* Response fields */
/* count is only an upper limit */
char em[255+1];
int i,mark=0;
if ((NewsGroupS = findgroup (groupName)) == NULL) {
/* Add group unsub'd to hash table */
@ -2605,7 +2592,7 @@ PUBLIC int HTLoadNews ARGS4(
{
char command[257]; /* The whole command */
char groupName[GROUP_NAME_LENGTH]; /* Just the group name */
char buf[LINE_LENGTH+1], *pt, *p1;
char buf[LINE_LENGTH+1], *p1;
int status; /* tcp return */
int retries; /* A count of how hard we have tried */
BOOL group_wanted; /* Flag: group was asked for, not article */
@ -2662,6 +2649,8 @@ PUBLIC int HTLoadNews ARGS4(
*/
if (!my_strncasecmp (arg, "news:", 5))
p1 = arg + 5; /* Skip "news:" prefix */
else
p1 = arg;
if (group_wanted) {
strcpy (command, "GROUP ");
first = 0;

@ -116,7 +116,6 @@ PUBLIC int HTLoadHTTP ARGS4 (
HTStream *target; /* Unconverted data */
HTFormat format_in; /* Format arriving in the message */
BOOL had_header; /* Have we had at least one header? */
char *line_buffer;
char *line_kept_clean;
BOOL extensions; /* Assume good HTTP server */
@ -133,10 +132,6 @@ PUBLIC int HTLoadHTTP ARGS4 (
/*SWP*/
int statusError=0;
char tmpbuf[4096];
char *begin_ptr,*tmp_ptr;
int env_length;
if (!arg)
{
@ -161,7 +156,6 @@ PUBLIC int HTLoadHTTP ARGS4 (
so we can start over here... */
eol = 0;
bytes_already_read = 0;
had_header = NO;
length = 0;
doing_redirect = 0;
compressed = 0;
@ -621,7 +615,6 @@ PUBLIC int HTLoadHTTP ARGS4 (
{
/* Get numeric status etc */
BOOL end_of_file = NO;
HTAtom * encoding = HTAtom_for("8bit");
int buffer_length = INIT_LINE_SIZE;
line_buffer = (char *) malloc(buffer_length * sizeof(char));

@ -226,8 +226,13 @@ customflags =
# ---------------------- END OF CUSTOMIZABLE OPTIONS -------------------------
# Disable certain warnings as we don't care for them
CWARNINGS = -Wno-parentheses -Wno-switch-enum
CFLAGS = -g $(sysconfigflags) $(prereleaseflags) $(CWARNINGS)
CWARNINGS = -Wall \
-Wno-parentheses \
-Wno-switch -Wno-switch-enum \
-Wno-char-subscripts \
-Wno-unused-result
CFLAGS = -g $(sysconfigflags) $(prereleaseflags) $(CWARNINGS) $(customflags)
# Don't worry about these -- for development purposes only.
PURIFY = purify