From: hno <> Date: Thu, 18 Oct 2001 02:25:01 +0000 (+0000) Subject: Many small compiler warning fixes, mainly const strings X-Git-Tag: SQUID_3_0_PRE1~1342 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a2c963ae500322dfeb7e7f0d8746c82b261df140;p=thirdparty%2Fsquid.git Many small compiler warning fixes, mainly const strings --- diff --git a/src/authenticate.cc b/src/authenticate.cc index 8a918b5629..5464b3af17 100644 --- a/src/authenticate.cc +++ b/src/authenticate.cc @@ -1,6 +1,6 @@ /* - * $Id: authenticate.cc,v 1.30 2001/10/03 20:12:47 hno Exp $ + * $Id: authenticate.cc,v 1.31 2001/10/17 20:25:01 hno Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Duane Wessels @@ -931,7 +931,7 @@ authenticateUserCacheRestart(void) * called to add another auth scheme module */ void -authSchemeAdd(char *type, AUTHSSETUP * setup) +authSchemeAdd(const char *type, AUTHSSETUP * setup) { int i; debug(29, 4) ("authSchemeAdd: adding %s\n", type); diff --git a/src/cachemgr.cc b/src/cachemgr.cc index 82e5dd4822..a340bf1f2a 100644 --- a/src/cachemgr.cc +++ b/src/cachemgr.cc @@ -1,6 +1,6 @@ /* - * $Id: cachemgr.cc,v 1.89 2001/08/31 11:19:12 robertc Exp $ + * $Id: cachemgr.cc,v 1.90 2001/10/17 20:25:01 hno Exp $ * * DEBUG: section 0 CGI Cache Manager * AUTHOR: Duane Wessels @@ -163,9 +163,9 @@ static struct in_addr no_addr; */ #define safe_free(str) { if (str) { xfree(str); (str) = NULL; } } static const char *safe_str(const char *str); -static char *xstrtok(char **str, char del); +static const char *xstrtok(char **str, char del); static void print_trailer(void); -static void auth_html(char *host, int port, const char *user_name); +static void auth_html(const char *host, int port, const char *user_name); static void error_html(const char *msg); static char *menu_url(cachemgr_request * req, const char *action); static int parse_status_line(const char *sline, const char **statusStr); @@ -192,7 +192,7 @@ is_number(const char *str) return strspn(str, "\t -+01234567890./\n") == strlen(str); } -static char * +static const char * xstrtok(char **str, char del) { if (*str) { @@ -226,7 +226,7 @@ print_trailer(void) } static void -auth_html(char *host, int port, const char *user_name) +auth_html(const char *host, int port, const char *user_name) { if (!user_name) user_name = ""; diff --git a/src/client.cc b/src/client.cc index a044ca154b..e860047e9f 100644 --- a/src/client.cc +++ b/src/client.cc @@ -1,6 +1,6 @@ /* - * $Id: client.cc,v 1.93 2001/02/23 20:59:50 hno Exp $ + * $Id: client.cc,v 1.94 2001/10/17 20:25:01 hno Exp $ * * DEBUG: section 0 WWW Client * AUTHOR: Harvest Derived @@ -40,8 +40,8 @@ #endif /* Local functions */ -static int client_comm_bind(int, char *); -static int client_comm_connect(int, char *, u_short, struct timeval *); +static int client_comm_bind(int, const char *); +static int client_comm_connect(int, const char *, u_short, struct timeval *); static void usage(const char *progname); static int Now(struct timeval *); static SIGHDLR catch; @@ -90,7 +90,7 @@ main(int argc, char *argv[]) int keep_alive = 0; int opt_noaccept = 0; int opt_verbose = 0; - char *hostname, *localhost; + const char *hostname, *localhost; char url[BUFSIZ], msg[BUFSIZ], buf[BUFSIZ]; char extra_hdrs[BUFSIZ]; const char *method = "GET"; @@ -355,7 +355,7 @@ main(int argc, char *argv[]) } static int -client_comm_bind(int sock, char *local_host) +client_comm_bind(int sock, const char *local_host) { static const struct hostent *hp = NULL; static struct sockaddr_in from_addr; @@ -374,7 +374,7 @@ client_comm_bind(int sock, char *local_host) } static int -client_comm_connect(int sock, char *dest_host, u_short dest_port, struct timeval *tvp) +client_comm_connect(int sock, const char *dest_host, u_short dest_port, struct timeval *tvp) { static const struct hostent *hp = NULL; static struct sockaddr_in to_addr; diff --git a/src/client_side.cc b/src/client_side.cc index 77d433f21c..13a38608fb 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.547 2001/10/12 23:33:01 hno Exp $ + * $Id: client_side.cc,v 1.548 2001/10/17 20:25:01 hno Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -2559,7 +2559,7 @@ parseHttpRequest(ConnStateData * conn, method_t * method_p, int *status, if (opt_accel_uses_host && (t = mime_get_header(req_hdr, "Host"))) { int vport; char *q; - char *protocol_name = "http"; + const char *protocol_name = "http"; if (vport_mode) vport = (int) ntohs(http->conn->me.sin_port); else diff --git a/src/comm.cc b/src/comm.cc index 0156980fb2..3960c40c39 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.321 2001/10/10 15:17:40 adrian Exp $ + * $Id: comm.cc,v 1.322 2001/10/17 20:25:01 hno Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -920,7 +920,7 @@ commHandleWrite(int fd, void *data) /* Select for Writing on FD, until SIZE bytes are sent. Call * *HANDLER when complete. */ void -comm_write(int fd, char *buf, int size, CWCB * handler, void *handler_data, FREE * free_func) +comm_write(int fd, const char *buf, int size, CWCB * handler, void *handler_data, FREE * free_func) { CommWriteStateData *state = fd_table[fd].rwstate; debug(5, 5) ("comm_write: FD %d: sz %d: hndl %p: data %p.\n", @@ -931,7 +931,7 @@ comm_write(int fd, char *buf, int size, CWCB * handler, void *handler_data, FREE fd_table[fd].rwstate = NULL; } fd_table[fd].rwstate = state = memPoolAlloc(comm_write_pool); - state->buf = buf; + state->buf = (char *) buf; state->size = size; state->offset = 0; state->handler = handler; diff --git a/src/ftp.cc b/src/ftp.cc index 1010c56c06..261d3fa9aa 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $Id: ftp.cc,v 1.312 2001/10/10 15:17:41 adrian Exp $ + * $Id: ftp.cc,v 1.313 2001/10/17 20:25:02 hno Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -163,7 +163,7 @@ static void ftpHackShortcut(FtpStateData * ftpState, FTPSM * nextState); static void ftpUnhack(FtpStateData * ftpState); static void ftpScheduleReadControlReply(FtpStateData *, int); static void ftpHandleControlReply(FtpStateData *); -static char *ftpHtmlifyListEntry(char *line, FtpStateData * ftpState); +static char *ftpHtmlifyListEntry(const char *line, FtpStateData * ftpState); static void ftpFailed(FtpStateData *, err_type); static void ftpFailedErrorMessage(FtpStateData *, err_type); @@ -635,7 +635,7 @@ dots_fill(size_t len) } static char * -ftpHtmlifyListEntry(char *line, FtpStateData * ftpState) +ftpHtmlifyListEntry(const char *line, FtpStateData * ftpState) { LOCAL_ARRAY(char, icon, 2048); LOCAL_ARRAY(char, href, 2048 + 40); @@ -687,7 +687,7 @@ ftpHtmlifyListEntry(char *line, FtpStateData * ftpState) return html; } if ((parts = ftpListParseParts(line, ftpState->flags)) == NULL) { - char *p; + const char *p; snprintf(html, 8192, "%s\n", line); for (p = line; *p && xisspace(*p); p++); if (*p && !xisspace(*p)) @@ -2378,7 +2378,7 @@ static void ftpFailedErrorMessage(FtpStateData * ftpState, err_type error) { ErrorState *err; - char *command, *reply; + const char *command, *reply; /* Translate FTP errors into HTTP errors */ err = NULL; switch (error) { @@ -2471,8 +2471,8 @@ ftpSendReply(FtpStateData * ftpState) static void ftpAppendSuccessHeader(FtpStateData * ftpState) { - char *mime_type = NULL; - char *mime_enc = NULL; + const char *mime_type = NULL; + const char *mime_enc = NULL; String urlpath = ftpState->request->urlpath; const char *filename = NULL; const char *t = NULL; diff --git a/src/globals.h b/src/globals.h index 5600fdbb8f..f67ac28f5e 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.107 2001/10/08 16:18:32 hno Exp $ + * $Id: globals.h,v 1.108 2001/10/17 20:25:02 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -39,7 +39,7 @@ extern SquidConfig Config; extern SquidConfig2 Config2; extern char *ConfigFile; /* NULL */ extern char *IcpOpcodeStr[]; -extern char *dns_error_message; /* NULL */ +extern const char *dns_error_message; /* NULL */ extern const char *log_tags[]; extern char tmp_error_buf[ERROR_BUF_SZ]; extern char *volatile debug_options; /* NULL */ diff --git a/src/helper.cc b/src/helper.cc index 6186d9e5c7..251b121e37 100644 --- a/src/helper.cc +++ b/src/helper.cc @@ -1,6 +1,6 @@ /* - * $Id: helper.cc,v 1.30 2001/08/29 14:57:35 robertc Exp $ + * $Id: helper.cc,v 1.31 2001/10/17 20:25:02 hno Exp $ * * DEBUG: section 29 Helper process maintenance * AUTHOR: Harvest Derived? @@ -64,7 +64,7 @@ helperOpenServers(helper * hlp) char *progname; char *shortname; char *procname; - char *args[HELPER_MAX_ARGS]; + const char *args[HELPER_MAX_ARGS]; char fd_note_buf[FD_DESC_SZ]; helper_server *srv; int nargs = 0; @@ -140,7 +140,7 @@ helperStatefulOpenServers(statefulhelper * hlp) char *progname; char *shortname; char *procname; - char *args[HELPER_MAX_ARGS]; + const char *args[HELPER_MAX_ARGS]; char fd_note_buf[FD_DESC_SZ]; helper_stateful_server *srv; int nargs = 0; diff --git a/src/http.cc b/src/http.cc index 6935ca923b..8b1e3579a6 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.382 2001/09/18 19:04:28 hno Exp $ + * $Id: http.cc,v 1.383 2001/10/17 20:25:02 hno Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -878,7 +878,7 @@ httpBuildRequestHeader(request_t * request, if (*orig_request->peer_login == '*') { /* Special mode, to pass the username to the upstream cache */ char loginbuf[256]; - char *username = "-"; + const char *username = "-"; if (orig_request->auth_user_request) username = authenticateUserRequestUsername(orig_request->auth_user_request); snprintf(loginbuf, sizeof(loginbuf), "%s%s", username, orig_request->peer_login + 1); diff --git a/src/ipc.cc b/src/ipc.cc index 80a3a85788..b8638d4530 100644 --- a/src/ipc.cc +++ b/src/ipc.cc @@ -1,6 +1,6 @@ /* - * $Id: ipc.cc,v 1.25 2001/10/17 19:43:39 hno Exp $ + * $Id: ipc.cc,v 1.26 2001/10/17 20:25:02 hno Exp $ * * DEBUG: section 54 Interprocess Communication * AUTHOR: Duane Wessels @@ -281,7 +281,7 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name #if HAVE_SETSID setsid(); #endif - execvp(prog, args); + execvp(prog, (char *const *) args); debug_log = fdopen(2, "a+"); debug(50, 0) ("ipcCreate: %s: %s\n", prog, xstrerror()); _exit(1); diff --git a/src/neighbors.cc b/src/neighbors.cc index 8b6c07b71a..b23f15dd15 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,6 +1,6 @@ /* - * $Id: neighbors.cc,v 1.298 2001/10/10 15:17:41 adrian Exp $ + * $Id: neighbors.cc,v 1.299 2001/10/17 20:25:02 hno Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -66,7 +66,7 @@ static u_short echo_port; static int NLateReplies = 0; static peer *first_ping = NULL; -char * +const char * neighborTypeStr(const peer * p) { if (p->type == PEER_NONE) diff --git a/src/peer_select.cc b/src/peer_select.cc index 62526c9465..d5b31b9c46 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_select.cc,v 1.115 2001/04/14 00:25:18 hno Exp $ + * $Id: peer_select.cc,v 1.116 2001/10/17 20:25:02 hno Exp $ * * DEBUG: section 44 Peer Selection Algorithm * AUTHOR: Duane Wessels @@ -66,7 +66,7 @@ static struct { int timeouts; } PeerStats; -static char *DirectStr[] = +static const char *DirectStr[] = { "DIRECT_UNKNOWN", "DIRECT_NO", diff --git a/src/protos.h b/src/protos.h index cabe09ce56..0e0e88d6c9 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.417 2001/10/17 19:43:39 hno Exp $ + * $Id: protos.h,v 1.418 2001/10/17 20:25:03 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -163,7 +163,7 @@ extern void comm_add_close_handler(int fd, PF *, void *); extern void comm_remove_close_handler(int fd, PF *, void *); extern int comm_udp_sendto(int, const struct sockaddr_in *, int, const void *, int); extern void comm_write(int fd, - char *buf, + const char *buf, int size, CWCB * handler, void *handler_data, @@ -666,7 +666,7 @@ extern void peerNoteDigestLookup(request_t * request, peer * p, lookup_t lookup) extern void peerNoteDigestGone(peer * p); extern int neighborUp(const peer * e); extern CBDUNL peerDestroy; -extern char *neighborTypeStr(const peer * e); +extern const char *neighborTypeStr(const peer * e); extern peer_t neighborType(const peer *, const request_t *); extern void peerConnectFailed(peer *); extern void peerConnectSucceded(peer *); @@ -769,7 +769,7 @@ extern char *authenticateUserUsername(auth_user_t *); extern char *authenticateUserRequestUsername(auth_user_request_t *); extern int authenticateValidateUser(auth_user_request_t *); extern void authenticateOnCloseConnection(ConnStateData * conn); -extern void authSchemeAdd(char *type, AUTHSSETUP * setup); +extern void authSchemeAdd(const char *type, AUTHSSETUP * setup); extern void refreshAddToList(const char *, int, time_t, int, time_t); extern int refreshIsCachable(const StoreEntry *); @@ -929,8 +929,8 @@ extern void storeHeapPositionUpdate(StoreEntry *, SwapDir *); extern void storeSwapFileNumberSet(StoreEntry * e, sfileno filn); extern void storeFsInit(void); extern void storeFsDone(void); -extern void storeFsAdd(char *, STSETUP *); -extern void storeReplAdd(char *, REMOVALPOLICYCREATE *); +extern void storeFsAdd(const char *, STSETUP *); +extern void storeReplAdd(const char *, REMOVALPOLICYCREATE *); /* store_modules.c */ extern void storeFsSetup(void); @@ -1082,7 +1082,7 @@ extern int intAverage(int, int, int, int); extern double doubleAverage(double, double, int, int); extern void debug_trap(const char *); extern void logsFlush(void); -extern char *checkNullString(char *p); +extern const char *checkNullString(const char *p); extern void squid_getrusage(struct rusage *r); extern double rusage_cputime(struct rusage *r); extern int rusage_maxrss(struct rusage *r); diff --git a/src/snmp_agent.cc b/src/snmp_agent.cc index cd101f6a4b..4d637d1f60 100644 --- a/src/snmp_agent.cc +++ b/src/snmp_agent.cc @@ -1,6 +1,6 @@ /* - * $Id: snmp_agent.cc,v 1.81 2001/08/31 11:19:12 robertc Exp $ + * $Id: snmp_agent.cc,v 1.82 2001/10/17 20:25:03 hno Exp $ * * DEBUG: section 49 SNMP Interface * AUTHOR: Kostas Anagnostakis @@ -77,7 +77,7 @@ variable_list * snmp_confFn(variable_list * Var, snint * ErrP) { variable_list *Answer = NULL; - char *cp = NULL; + const char *cp = NULL; debug(49, 5) ("snmp_confFn: Processing request with magic %d!\n", Var->name[8]); *ErrP = SNMP_ERR_NOERROR; switch (Var->name[LEN_SQ_CONF]) { diff --git a/src/store.cc b/src/store.cc index ce70b6e681..253c768daf 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.541 2001/09/07 18:02:46 adrian Exp $ + * $Id: store.cc,v 1.542 2001/10/17 20:25:03 hno Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -1319,7 +1319,7 @@ storeFsDone(void) * called to add another store fs module */ void -storeFsAdd(char *type, STSETUP * setup) +storeFsAdd(const char *type, STSETUP * setup) { int i; /* find the number of currently known storefs types */ @@ -1338,7 +1338,7 @@ storeFsAdd(char *type, STSETUP * setup) * called to add another store removal policy module */ void -storeReplAdd(char *type, REMOVALPOLICYCREATE * create) +storeReplAdd(const char *type, REMOVALPOLICYCREATE * create) { int i; /* find the number of currently known repl types */ diff --git a/src/store_log.cc b/src/store_log.cc index c0ca87ac1b..0b5684cdbd 100644 --- a/src/store_log.cc +++ b/src/store_log.cc @@ -1,6 +1,6 @@ /* - * $Id: store_log.cc,v 1.22 2001/02/17 07:28:50 hno Exp $ + * $Id: store_log.cc,v 1.23 2001/10/17 20:25:03 hno Exp $ * * DEBUG: section 20 Storage Manager Logging Functions * AUTHOR: Duane Wessels @@ -35,7 +35,7 @@ #include "squid.h" -static char *storeLogTags[] = +static const char *storeLogTags[] = { "CREATE", "SWAPIN", diff --git a/src/structs.h b/src/structs.h index bd93a5086b..9f59b60f00 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.404 2001/10/17 19:43:39 hno Exp $ + * $Id: structs.h,v 1.405 2001/10/17 20:25:03 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -146,7 +146,7 @@ struct _auth_user_request_t { */ struct _authscheme_entry { - char *typestr; + const char *typestr; AUTHSACTIVE *Active; AUTHSADDHEADER *AddHeader; AUTHSADDTRAILER *AddTrailer; @@ -177,7 +177,7 @@ struct _authscheme_entry { /* private data types */ struct _authScheme { /* pointer to the authscheme_list's string entry */ - char *typestr; + const char *typestr; /* the scheme id in the authscheme_list */ int Id; /* the scheme's configuration details. */ @@ -1520,7 +1520,7 @@ struct _StoreEntry { }; struct _SwapDir { - char *type; + const char *type; int cur_size; int low_size; int max_size; @@ -1658,7 +1658,7 @@ struct _cachemgr_passwd { }; struct _refresh_t { - char *pattern; + const char *pattern; regex_t compiled_pattern; time_t min; double pct; @@ -2108,7 +2108,7 @@ struct _store_rebuild_data { */ struct _storefs_entry { - char *typestr; + const char *typestr; STFSPARSE *parsefunc; STFSRECONFIGURE *reconfigurefunc; STFSSHUTDOWN *donefunc; @@ -2119,7 +2119,7 @@ struct _storefs_entry { */ struct _storerepl_entry { - char *typestr; + const char *typestr; REMOVALPOLICYCREATE *create; }; diff --git a/src/tools.cc b/src/tools.cc index 3d009a3d77..99fc903d92 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1,6 +1,6 @@ /* - * $Id: tools.cc,v 1.209 2001/08/16 00:16:19 hno Exp $ + * $Id: tools.cc,v 1.210 2001/10/17 20:25:03 hno Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -761,8 +761,8 @@ logsFlush(void) fflush(debug_log); } -char * -checkNullString(char *p) +const char * +checkNullString(const char *p) { return p ? p : "(NULL)"; } diff --git a/src/unlinkd.cc b/src/unlinkd.cc index 11c3719ddc..2d71381f18 100644 --- a/src/unlinkd.cc +++ b/src/unlinkd.cc @@ -1,6 +1,6 @@ /* - * $Id: unlinkd.cc,v 1.43 2001/02/23 20:59:51 hno Exp $ + * $Id: unlinkd.cc,v 1.44 2001/10/17 20:25:03 hno Exp $ * * DEBUG: section 12 Unlink Daemon * AUTHOR: Duane Wessels @@ -159,7 +159,7 @@ void unlinkdInit(void) { int x; - char *args[2]; + const char *args[2]; struct timeval slp; args[0] = "(unlinkd)"; args[1] = NULL;