1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-15 04:28:09 -04:00

Enabled lots of GCC warnings, fixed those that were easy to fix.

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@456 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2000-07-10 23:00:56 +00:00 committed by cras
parent f8aa81b73c
commit dcc2e89b2e
25 changed files with 84 additions and 106 deletions

View File

@ -21,7 +21,7 @@
#include "module.h"
#include "levels.h"
static char *levels[] =
static const char *levels[] =
{
"CRAP",
"MSGS",

View File

@ -168,8 +168,10 @@ int copyfile(const char *src, const char *dest)
int len;
char buf[1024];
while ((len = fread(buf, 1, sizeof(buf), fs)) > 0)
if (fwrite(buf, 1, len, fd) != len) break;
while ((len = fread(buf, 1, sizeof(buf), fs)) > 0) {
if (fwrite(buf, 1, len, fd) != len)
break;
}
fclose(fd);
ret = TRUE;
}
@ -330,8 +332,10 @@ char *stristr(const char *data, const char *key)
return NULL;
max = data+datalen-keylen;
for (pos = data; pos <= max; pos++)
if (g_strncasecmp(pos, key, keylen) == 0) return (char *) pos;
for (pos = data; pos <= max; pos++) {
if (g_strncasecmp(pos, key, keylen) == 0)
return (char *) pos;
}
return NULL;
}
@ -397,12 +401,12 @@ int g_istr_cmp(gconstpointer v, gconstpointer v2)
/* a char* hash function from ASU */
unsigned int g_istr_hash(gconstpointer v)
{
const char *s = (char *) v;
const char *s = (const char *) v;
unsigned int h = 0, g;
while (*s != '\0') {
h = (h << 4) + toupper(*s);
if ((g = h & 0xf0000000)) {
if ((g = h & 0xf0000000UL)) {
h = h ^ (g >> 24);
h = h ^ g;
}

View File

@ -403,7 +403,7 @@ int net_ip2host(IPADDR *ip, char *host)
ip4 = ntohl(ip->addr.ip.s_addr);
sprintf(host, "%lu.%lu.%lu.%lu",
(ip4 & 0xff000000) >> 24,
(ip4 & 0xff000000UL) >> 24,
(ip4 & 0x00ff0000) >> 16,
(ip4 & 0x0000ff00) >> 8,
(ip4 & 0x000000ff));

View File

@ -94,7 +94,7 @@ static void signal_destroy(int signal_id)
static int signal_list_find(GPtrArray *array, void *data)
{
int n;
unsigned int n;
for (n = 0; n < array->len; n++) {
if (g_ptr_array_index(array, n) == data)

View File

@ -27,8 +27,8 @@
#include "completion.h"
#define wordreplace_find(replace) \
iconfig_list_find("replaces", "text", replace, "replace")
#define wordreplace_find(word) \
iconfig_list_find("replaces", "text", word, "replace")
#define completion_find(completion) \
iconfig_list_find("completions", "short", completion, "long")

View File

@ -67,7 +67,8 @@ static void cmd_set(char *data)
{
GHashTable *optlist;
GSList *sets, *tmp;
char *key, *value, *last_section;
const char *last_section;
char *key, *value;
void *free_arg;
int found, clear;

View File

@ -361,14 +361,16 @@ static void cmd_format(const char *data)
"format", &optlist, &module, &key, &value))
return;
modules = get_sorted_modules();
if (*module != '\0' && theme_search(modules, module) == NULL) {
modules = get_sorted_modules();
if (*module == '\0')
module = NULL;
else if (theme_search(modules, module) == NULL) {
/* first argument isn't module.. */
cmd_params_free(free_arg);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST | PARAM_FLAG_OPTIONS,
"format", &optlist, &key, &value))
return;
module = "";
module = NULL;
}
reset = FALSE;
@ -383,7 +385,7 @@ static void cmd_format(const char *data)
for (tmp = modules; tmp != NULL; tmp = tmp->next) {
THEME_SEARCH_REC *rec = tmp->data;
if (*module == '\0' || g_strcasecmp(rec->short_name, module) == 0)
if (module == NULL || g_strcasecmp(rec->short_name, module) == 0)
theme_show(rec, key, value, reset);
}
g_slist_foreach(modules, (GFunc) g_free, NULL);

View File

@ -67,17 +67,23 @@ static void ctcp_time_msg(const char *data, IRC_SERVER_REC *server, const char *
static void ctcp_default_reply(const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr, const char *target)
{
char *ptr, *str;
const char *ctcpdata;
char *ctcp, *ptr;
g_return_if_fail(data != NULL);
str = g_strdup(data);
ptr = strchr(str, ' ');
if (ptr != NULL) *ptr++ = '\0'; else ptr = "";
ctcp = g_strdup(data);
ptr = strchr(ctcp, ' ');
if (ptr == NULL)
ctcpdata = "";
else {
*ptr = '\0';
ctcpdata = ptr+1;
}
printformat(server, ischannel(*target) ? target : nick, MSGLEVEL_CTCPS,
ischannel(*target) ? IRCTXT_CTCP_REPLY_CHANNEL : IRCTXT_CTCP_REPLY, str, nick, ptr, target);
g_free(str);
ischannel(*target) ? IRCTXT_CTCP_REPLY_CHANNEL : IRCTXT_CTCP_REPLY, ctcp, nick, ctcpdata, target);
g_free(ctcp);
}
static void ctcp_ping_reply(const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr, const char *target)

View File

@ -60,7 +60,8 @@ static void print_channel_msg(IRC_SERVER_REC *server, const char *msg,
CHANNEL_REC *chanrec;
NICK_REC *nickrec;
int for_me;
char *color, *nickmode;
const char *nickmode;
char *color;
chanrec = channel_find(server, target);
for_me = irc_nick_match(server->nick, msg);

View File

@ -165,7 +165,7 @@ static void cmd_ignore(const char *data)
if (ischannel(*mask)) {
chanarg = mask;
mask = "";
mask = NULL;
}
channels = (chanarg == NULL || *chanarg == '\0') ? NULL :
g_strsplit(replace_chars(chanarg, ',', ' '), " ", -1);
@ -176,7 +176,8 @@ static void cmd_ignore(const char *data)
if (rec == NULL) {
rec = g_new0(IGNORE_REC, 1);
rec->mask = *mask == '\0' ? NULL : g_strdup(mask);
rec->mask = (mask != NULL && *mask != '\0') ?
g_strdup(mask) : NULL;
rec->channels = channels;
} else {
g_free_and_null(rec->pattern);
@ -226,10 +227,10 @@ static void cmd_unignore(const char *data)
rec = tmp == NULL ? NULL : tmp->data;
} else {
/* with mask */
char *chans[2] = { "*", NULL };
const char *chans[2] = { "*", NULL };
if (ischannel(*data)) chans[0] = (char *) data;
rec = ignore_find("*", ischannel(*data) ? NULL : data, chans);
if (ischannel(*data)) chans[0] = data;
rec = ignore_find("*", ischannel(*data) ? NULL : data, (char **) chans);
}
if (rec == NULL)

View File

@ -95,7 +95,8 @@ static void cmd_msg(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
WINDOW_REC *window;
CHANNEL_REC *channel;
NICK_REC *nickrec;
char *target, *msg, *nickmode, *freestr, *newtarget;
const char *nickmode;
char *target, *msg, *freestr, *newtarget;
void *free_arg;
int free_ret;

View File

@ -30,13 +30,13 @@
#include "screen.h"
#include "gui-windows.h"
#define TEXT_CHUNK_USABLE_SIZE (LINE_TEXT_CHUNK_SIZE-2-sizeof(char*))
#define TEXT_CHUNK_USABLE_SIZE (LINE_TEXT_CHUNK_SIZE-2-(int)sizeof(char*))
int mirc_colors[] = { 15, 0, 1, 2, 12, 6, 5, 4, 14, 10, 3, 11, 9, 13, 8, 7, 15 };
static int scrollback_lines, scrollback_hours;
#define mark_temp_eol(text) \
memcpy((text)->buffer + (text)->pos, "\0\x80", 2);
memcpy((text)->buffer + (text)->pos, "\0\200", 2);
static LINE_REC *create_line(GUI_WINDOW_REC *gui, int level)
{
@ -191,7 +191,7 @@ static void get_colors(int flags, int *fg, int *bg)
if (flags & PRINTFLAG_BLINK) *bg |= 0x80;
}
static void linebuf_add(GUI_WINDOW_REC *gui, char *str, int len)
static void linebuf_add(GUI_WINDOW_REC *gui, const char *str, int len)
{
int left;
@ -271,7 +271,7 @@ static void gui_printtext(WINDOW_REC *window, gpointer fgcolor, gpointer bgcolor
/* \n can be only at the start of the line.. */
if (*str == '\n') {
str++;
linebuf_add(gui, "\0\x80", 2); /* mark EOL */
linebuf_add(gui, "\0\200", 2); /* mark EOL */
line = create_line(gui, 0);
gui_window_newline(gui, visible);

View File

@ -408,7 +408,7 @@ static void sig_addchar(const char *data)
gui_entry_insert_char(*data);
}
static void sig_window_auto_changed(WINDOW_REC *window)
static void sig_window_auto_changed(void)
{
command_history_next(active_win, gui_entry_get_text());
gui_entry_set_text("");
@ -452,12 +452,12 @@ void gui_readline_init(void)
key_bind("prev page", "Previous page", "ALT-P", NULL, (SIGNAL_FUNC) sig_prev_page);
key_bind("next page", "Next page", "ALT-N", NULL, (SIGNAL_FUNC) sig_next_page);
key_bind("special char", "Insert special character", "CTRL-B", "\x02", (SIGNAL_FUNC) sig_addchar);
key_bind("special char", NULL, "CTRL--", "\x1f", (SIGNAL_FUNC) sig_addchar);
key_bind("special char", NULL, "CTRL-C", "\x03", (SIGNAL_FUNC) sig_addchar);
key_bind("special char", NULL, "CTRL-V", "\x16", (SIGNAL_FUNC) sig_addchar);
key_bind("special char", NULL, "CTRL-G", "\x07", (SIGNAL_FUNC) sig_addchar);
key_bind("special char", NULL, "CTRL-O", "\x0f", (SIGNAL_FUNC) sig_addchar);
key_bind("special char", "Insert special character", "CTRL-B", "\002", (SIGNAL_FUNC) sig_addchar);
key_bind("special char", NULL, "CTRL--", "\037", (SIGNAL_FUNC) sig_addchar);
key_bind("special char", NULL, "CTRL-C", "\003", (SIGNAL_FUNC) sig_addchar);
key_bind("special char", NULL, "CTRL-V", "\026", (SIGNAL_FUNC) sig_addchar);
key_bind("special char", NULL, "CTRL-G", "\007", (SIGNAL_FUNC) sig_addchar);
key_bind("special char", NULL, "CTRL-O", "\017", (SIGNAL_FUNC) sig_addchar);
for (n = 0; changekeys[n] != '\0'; n++) {
key = g_strdup_printf("ALT-%c", changekeys[n]);

View File

@ -18,7 +18,10 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE /* for crypt() */
#endif
#include "module.h"
#include "signals.h"
#include "misc.h"

View File

@ -37,7 +37,7 @@ void botnet_users_init(void);
GSList *botnets;
void bot_send_cmd(BOT_REC *bot, char *data)
void bot_send_cmd(BOT_REC *bot, const char *data)
{
g_return_if_fail(bot != NULL);
g_return_if_fail(data != NULL);
@ -46,7 +46,7 @@ void bot_send_cmd(BOT_REC *bot, char *data)
net_transmit(bot->handle, "\n", 1);
}
void bot_send_cmdv(BOT_REC *bot, char *format, ...)
void bot_send_cmdv(BOT_REC *bot, const char *format, ...)
{
va_list args;
char *str;

View File

@ -95,8 +95,8 @@ struct _botnet_rec {
extern GSList *botnets;
void bot_send_cmd(BOT_REC *bot, char *data);
void bot_send_cmdv(BOT_REC *bot, char *format, ...);
void bot_send_cmd(BOT_REC *bot, const char *data);
void bot_send_cmdv(BOT_REC *bot, const char *format, ...);
/* broadcast a message to everyone in bot network, except for `except_bot'
if it's not NULL. If botnet is NULL, the message is sent to all botnets. */

View File

@ -268,7 +268,7 @@ static void dcc_ctcp_msg(const char *data, IRC_SERVER_REC *server,
{
char *type, *arg, *portstr, *sizestr;
void *free_arg;
unsigned long size;
long size;
int port;
DCC_REC *dcc;
@ -426,7 +426,7 @@ static void dcc_send_read_size(DCC_REC *dcc)
memcpy(&bytes, dcc->count_buf, 4);
bytes = (guint32) ntohl(bytes);
dcc->gotalldata = bytes == dcc->transfd;
dcc->gotalldata = (long) bytes == dcc->transfd;
dcc->count_pos = 0;
if (!dcc->fastsend) {

View File

@ -38,7 +38,7 @@ void dcc_files_deinit(void);
#define DCC_TYPES 5
static char *dcc_types[] = {
static const char *dcc_types[] = {
"CHAT",
"SEND",
"GET",
@ -282,7 +282,7 @@ static void dcc_ctcp_msg(char *data, IRC_SERVER_REC *server, char *sender, char
void *free_arg;
const char *cstr;
DCC_REC *dcc;
gulong size;
long size;
int port;
g_return_if_fail(data != NULL);
@ -293,7 +293,7 @@ static void dcc_ctcp_msg(char *data, IRC_SERVER_REC *server, char *sender, char
return;
if (sscanf(portstr, "%d", &port) != 1) port = 0;
if (sscanf(sizestr, "%lu", &size) != 1) size = 0;
if (sscanf(sizestr, "%ld", &size) != 1) size = 0;
dcc = dcc_create(SWAP_SENDGET(dcc_str2type(type)), -1, sender, arg, server, chat);
dcc_get_address(addrstr, &dcc->addr);

View File

@ -28,12 +28,12 @@ static int g_istr_equal(gconstpointer v, gconstpointer v2)
/* a char* hash function from ASU */
static unsigned int g_istr_hash(gconstpointer v)
{
const char *s = (char *) v;
const char *s = (const char *) v;
unsigned int h = 0, g;
while (*s != '\0') {
h = (h << 4) + toupper(*s);
if ((g = h & 0xf0000000)) {
if ((g = h & 0xf0000000UL)) {
h = h ^ (g >> 24);
h = h ^ g;
}

View File

@ -1,5 +1,9 @@
noinst_LTLIBRARIES = libpopt.la
INCLUDES = \
$(GLIB_CFLAGS) \
-I$(top_srcdir)/src
libpopt_la_SOURCES = \
findme.c popt.c poptconfig.c popthelp.c poptparse.c

View File

@ -2,14 +2,8 @@
file accompanying popt source distributions, available from
ftp://ftp.redhat.com/pub/code/popt */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "common.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef __NeXT
/* access macros are not declared in non posix mode in unistd.h -
don't try to use posix on NeXTstep 3.3 ! */
@ -31,7 +25,7 @@ char * findProgramPath(char * argv0) {
/* If there is a / in the argv[0], it has to be an absolute
path */
if (strchr(argv0, '/'))
return strdup(argv0);
return g_strdup(argv0);
if (!path) return NULL;

View File

@ -2,18 +2,7 @@
file accompanying popt source distributions, available from
ftp://ftp.redhat.com/pub/code/popt */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <errno.h>
#include <ctype.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "common.h"
#if HAVE_ALLOCA_H
# include <alloca.h>
@ -25,7 +14,7 @@
void poptSetExecPath(poptContext con, const char * path, int allowAbsolute) {
if (con->execPath) free(con->execPath);
con->execPath = strdup(path);
con->execPath = g_strdup(path);
con->execAbsolute = allowAbsolute;
}
@ -449,7 +438,7 @@ int poptGetNextOpt(poptContext con) {
if (opt->arg && (opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE
&& (opt->argInfo & POPT_ARG_MASK) != POPT_ARG_VAL)
con->finalArgv[con->finalArgvCount++] = strdup(con->os->nextArg);
con->finalArgv[con->finalArgvCount++] = g_strdup(con->os->nextArg);
}
return opt->val;

View File

@ -2,16 +2,7 @@
file accompanying popt source distributions, available from
ftp://ftp.redhat.com/pub/code/popt */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "common.h"
#if HAVE_ALLOCA_H
# include <alloca.h>
@ -58,12 +49,12 @@ static void configLine(poptContext con, char * line) {
con->execs = realloc(con->execs,
sizeof(*con->execs) * (con->numExecs + 1));
if (longName)
con->execs[con->numExecs].longName = strdup(longName);
con->execs[con->numExecs].longName = g_strdup(longName);
else
con->execs[con->numExecs].longName = NULL;
con->execs[con->numExecs].shortName = shortName;
con->execs[con->numExecs].script = strdup(line);
con->execs[con->numExecs].script = g_strdup(line);
con->numExecs++;
}

View File

@ -4,14 +4,7 @@
file accompanying popt source distributions, available from
ftp://ftp.redhat.com/pub/code/popt */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
@ -302,5 +295,5 @@ void poptPrintUsage(poptContext con, FILE * f, int flags) {
void poptSetOtherOptionHelp(poptContext con, const char * text) {
if (con->otherHelp) free(con->otherHelp);
con->otherHelp = strdup(text);
con->otherHelp = g_strdup(text);
}

View File

@ -43,16 +43,6 @@ struct poptContext_s {
char * otherHelp;
};
#ifdef HAVE_LIBINTL_H
#include <libintl.h>
#endif
#ifdef HAVE_GETTEXT
#define _(foo) gettext(foo)
#else
#define _(foo) (foo)
#endif
#ifdef HAVE_DGETTEXT
#define D_(dom, str) dgettext(dom, str)
#define POPT_(foo) D_("popt", foo)
@ -61,6 +51,4 @@ struct poptContext_s {
#define D_(dom, str) (str)
#endif
#define N_(foo) (foo)
#endif