Fix some obvious type warnings.

This commit is contained in:
Arnavion 2014-12-04 04:06:38 -08:00
parent 3fbe5b876e
commit 8062bce835
18 changed files with 152 additions and 183 deletions

View File

@ -14,54 +14,25 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/* char *split(char *text, char separator)
typedef int (*MYPROC)(HWND,HWND,char*,char*,BOOL,BOOL);
int dllProc(char *name, char *data){
HINSTANCE hinstLib;
hinstLib = LoadLibrary("mpcinfo");
//MYPROC proc;
int res;
if (hinstLib != NULL){
//proc = ;
if ((MYPROC) GetProcAddress(hinstLib, name)!=NULL){
res=(MYPROC)(NULL,NULL,data,NULL,TRUE,TRUE);
}
else{fprintf(stderr,"can't get proc: %s\n",name);res=-2;}
}
else{fprintf(stderr,"can't access dll\n");return -1;}
FreeLibrary(hinstLib);
return res;
}
*/
/*
int dllProc(char *name, char *data)
{ {
static HMODULE lib = NULL; int pos = -1;
if (!lib) size_t i;
for (i = 0; i < strlen(text); i++)
{ {
lib = LoadLibraryA ("mpcinfo"); if (text[i] == separator) {
if (!lib) pos = i;
{ i = strlen(text) + 1;
return FALSE;
} }
FreeLibrary (lib);
} }
return TRUE; if (pos == -1)
} {
*/ return text;
}
char *split(char *text, char seperator){ text[pos] = 0;
//if (DEBUG==1) putlog("splitting"); return &(text[pos + 1]);
int i;int pos=-1;
for (i=0;i<strlen(text);i++){
if (text[i]==seperator){pos=i;i=strlen(text)+1;}
}
if (pos==-1) return text;
text[pos]=0;
return &(text[pos+1]);
} }
int endsWith(char *text, char *suffix){ int endsWith(char *text, char *suffix){
@ -71,15 +42,26 @@ int endsWith(char *text, char *suffix){
return 0; return 0;
} }
int inStr(char *s1, int sl1, char *s2){ int inStr(char *s1, size_t sl1, char *s2)
//if (DEBUG==1) putlog("checking instr"); {
int i;int j; size_t i;
for(i=0;i<sl1-strlen(s2);i++){ for (i = 0; i < sl1 - strlen(s2); i++)
for (j=0;j<strlen(s2);j++){ {
if (s1[i+j]!=s2[j]) j=strlen(s2)+2; size_t j;
for (j = 0; j < strlen(s2); j++)
{
if (s1[i + j] != s2[j])
{
j = strlen(s2) + 2;
}
}
if (j == strlen(s2))
{
return i;
} }
if (j==strlen(s2)) return i;
} }
return -1; return -1;
} }
@ -121,14 +103,19 @@ char *readLine(FILE *f){
return buffer; return buffer;
} }
char *toUpper(char *text){ char *toUpper(char *text)
//if (DEBUG==1) putlog("converting text to upper case"); {
char *ret=(char*) calloc(strlen(text)+1,sizeof(char)); char *ret = (char*) calloc(strlen(text) + 1, sizeof(char));
int i;
for (i=0;i<strlen(text);i++) ret[i]=toupper(text[i]); size_t i;
ret[strlen(text)]=0; for (i = 0; i < strlen(text); i++)
//if (DEBUG==1) putlog("uc done"); {
return ret; ret[i] = toupper(text[i]);
}
ret[strlen(text)] = 0;
return ret;
} }
static char *str3cat(char *s1, char *s2, char *s3){ static char *str3cat(char *s1, char *s2, char *s3){

View File

@ -75,62 +75,25 @@ static char MODES [][13]={"Stereo","Joint-Stereo","Dual-Channel","Mono"};
int iPow(int x, int y){return (int)(pow((double)x,(double) y));} int iPow(int x, int y){return (int)(pow((double)x,(double) y));}
int str2int(char *text){ int str2int(char *text)
//if (DEBUG==1) putlog("converting string to int"); {
int i; int ret = 0;
int ret=0;
for (i=1;i<=strlen(text);i++){
if ((text[strlen(text)-i]>57)||(text[strlen(text)-i]<48)){
hexchat_printf(ph,"invalid char in string: %i",text[strlen(text)-i]);
return 255;
}
ret+=((int)text[strlen(text)-i]-48)*iPow(10,i-1);
}
//hexchat_printf(ph, "str2int(%s)=%i",text,ret);
//if (DEBUG==1) putlog("int converted");
return ret;
}
/*
static int getSize(char *file){
//if (DEBUG==1) putlog("reading filesize");
struct stat info;
if (stat(file,&info)!=0) return -1;
return info.st_size;
}*/
/*
int inStr(char *s1, int sl1, char *s2){
//if (DEBUG==1) putlog("checking instr");
int i;int j;
for(i=0;i<sl1-strlen(s2);i++){
for (j=0;j<strlen(s2);j++){
if (s1[i+j]!=s2[j]) j=strlen(s2)+2;
}
if (j==strlen(s2)) return i;
}
return -1;
}
static char *subString(char *text, int first, int length, int spcKill){ size_t i;
//if (DEBUG==1) putlog("creating substring"); for (i = 1; i <= strlen(text); i++)
char *ret=(char*) calloc (length+1,sizeof(char)); //malloc(sizeof(char)*(length+1)); {
ret[length]=0;int i; if ((text[strlen(text) - i] > 57) || (text[strlen(text) - i] < 48))
for (i=0;i<length;i++){ {
ret[i]=text[i+first]; hexchat_printf(ph, "invalid char in string: %i", (int) text[strlen(text) - i]);
//if (ret[i]==0) ret[i]='0'; return 255;
}
ret += ((int) text[strlen(text) - i] - 48)*iPow(10, i - 1);
} }
if (spcKill==1){
for (i=length-1;i>=0;i--){
if (ret[i]==32) ret[i]=0;
else i=-1;
}
}
//if (DEBUG==1) putlog("substring created");
return ret; return ret;
} }
static char *substring(char *text, int first, int length){return subString(text,first,length,0);} //1
*/
static char *tagExtract(char *tag, int tagLen, char* info){ static char *tagExtract(char *tag, int tagLen, char* info){
//if (DEBUG==1) putlog("extracting tag"); //if (DEBUG==1) putlog("extracting tag");
int pos, len, i; int pos, len, i;
@ -204,23 +167,28 @@ struct tagInfo readID3V1(char *file){
return ret; return ret;
} }
char *extractID3Genre(char *tag){ char *extractID3Genre(char *tag)
//if (DEBUG==1) putlog("extracting id3 genre"); {
if (tag[strlen(tag)-1]==')'){ if (tag[strlen(tag) - 1] == ')')
tag[strlen(tag)-1]=0; {
tag=&tag[1]; tag[strlen(tag) - 1] = 0;
return GENRES[str2int(tag)]; tag = &tag[1];
//return tag; return GENRES[str2int(tag)];
} }
else{ else
int i; {
//hexchat_print(ph, "Using 2 criteria"); size_t i;
for (i=0;i<strlen(tag);i++){ for (i = 0; i < strlen(tag); i++)
if (tag[i]==')'){ tag=&tag[i]+1;return tag;} {
//return tag; if (tag[i] == ')')
} {
} tag = &tag[i] + 1;
return "[152] failed"; return tag;
}
}
}
return "[152] failed";
} }
struct tagInfo readID3V2(char *file){ struct tagInfo readID3V2(char *file){

View File

@ -25,14 +25,18 @@ static int getOggInt(char *buff, int beg, int bytes){
return ret; return ret;
} }
static char *upperStr(char *text){ static char *upperStr(char *text)
//if (DEBUG==1) putlog("converting text to uc"); {
//printf("upperStr(%s)\n",text); char *ret = (char*) malloc(sizeof(char)*(strlen(text) + 1));
int i;
char *ret=(char*) malloc(sizeof(char)*(strlen(text)+1)); size_t i;
ret[strlen(text)]=0; for (i = 0; i < strlen(text); i++)
for (i=0;i<strlen(text);i++) ret[i]=toupper(text[i]); {
//printf("Result: %s\n",ret); ret[i] = toupper(text[i]);
}
ret[strlen(text)] = 0;
return ret; return ret;
} }

View File

@ -49,24 +49,32 @@ void printThemes(){
hexchat_printf(ph,"\nTitle-Theme:\n");printTheme(titleTheme); hexchat_printf(ph,"\nTitle-Theme:\n");printTheme(titleTheme);
} }
void cbFix(char *line){ void cbFix(char *line)
//if (DEBUG==1) putlog("cbfix"); {
int i, j; size_t i;
for (i=0;i<strlen(line);i++){ for (i = 0; i < strlen(line); i++)
if (line[i]=='%'){ {
if ((line[i+1]=='C')||(line[i+1]=='B')||(line[i+1]=='U')||(line[i+1]=='O')||(line[i+1]=='R')){ size_t j;
if(line[i+1]=='C') line[i]=3;
if(line[i+1]=='B') line[i]=2;
if(line[i+1]=='U') line[i]=37;
if(line[i+1]=='O') line[i]=17;
if(line[i+1]=='R') line[i]=26;
for (j=i+1;j<strlen(line)-1;j++) line[j]=line[j+1]; if (line[i] == '%')
line[strlen(line)-1]=0; {
} if ((line[i + 1] == 'C') || (line[i + 1] == 'B') || (line[i + 1] == 'U') || (line[i + 1] == 'O') || (line[i + 1] == 'R'))
} {
} if (line[i + 1] == 'C') line[i] = 3;
//if (DEBUG==1) putlog("cbfix done"); if (line[i + 1] == 'B') line[i] = 2;
if (line[i + 1] == 'U') line[i] = 37;
if (line[i + 1] == 'O') line[i] = 17;
if (line[i + 1] == 'R') line[i] = 26;
for (j = i + 1; j < strlen(line) - 1; j++)
{
line[j] = line[j + 1];
}
line[strlen(line) - 1] = 0;
}
}
}
} }
struct theme themeAdd(struct theme data, char *info){ struct theme themeAdd(struct theme data, char *info){

View File

@ -753,7 +753,7 @@ XS (XS_HexChat_send_modes)
} }
if (target_count == 0) { if (target_count == 0) {
free (targets); free ((char**) targets);
XSRETURN_EMPTY; XSRETURN_EMPTY;
} }
@ -765,7 +765,7 @@ XS (XS_HexChat_send_modes)
} }
hexchat_send_modes (ph, targets, target_count, modes_per_line, sign, mode); hexchat_send_modes (ph, targets, target_count, modes_per_line, sign, mode);
free (targets); free ((char**) targets);
} }
} }
static static

View File

@ -586,10 +586,10 @@ const struct prefs vars[] =
{0, 0, 0}, {0, 0, 0},
}; };
static char * static const char *
convert_with_fallback (const char *str, const char *fallback) convert_with_fallback (const char *str, const char *fallback)
{ {
char *utf; const char *utf;
#ifndef WIN32 #ifndef WIN32
/* On non-Windows, g_get_user_name and g_get_real_name return a string in system locale, so convert it to utf-8. */ /* On non-Windows, g_get_user_name and g_get_real_name return a string in system locale, so convert it to utf-8. */

View File

@ -260,7 +260,7 @@ lag_check (void)
unsigned long tim; unsigned long tim;
char tbuf[128]; char tbuf[128];
time_t now = time (0); time_t now = time (0);
int lag; time_t lag;
tim = make_ping_time (); tim = make_ping_time ();
@ -270,14 +270,15 @@ lag_check (void)
if (serv->connected && serv->end_of_motd) if (serv->connected && serv->end_of_motd)
{ {
lag = now - serv->ping_recv; lag = now - serv->ping_recv;
if (prefs.hex_net_ping_timeout && lag > prefs.hex_net_ping_timeout && lag > 0) if (prefs.hex_net_ping_timeout != 0 && lag > prefs.hex_net_ping_timeout && lag > 0)
{ {
sprintf (tbuf, "%d", lag); sprintf (tbuf, "%" G_GINT64_FORMAT, (gint64) lag);
EMIT_SIGNAL (XP_TE_PINGTIMEOUT, serv->server_session, tbuf, NULL, EMIT_SIGNAL (XP_TE_PINGTIMEOUT, serv->server_session, tbuf, NULL,
NULL, NULL, 0); NULL, NULL, 0);
if (prefs.hex_net_auto_reconnect) if (prefs.hex_net_auto_reconnect)
serv->auto_reconnect (serv, FALSE, -1); serv->auto_reconnect (serv, FALSE, -1);
} else }
else
{ {
snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim); snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim);
serv->p_ping (serv, "", tbuf); serv->p_ping (serv, "", tbuf);
@ -396,7 +397,6 @@ irc_init (session *sess)
{ {
static int done_init = FALSE; static int done_init = FALSE;
char *buf; char *buf;
int i;
if (done_init) if (done_init)
return; return;
@ -431,7 +431,8 @@ irc_init (session *sess)
if (arg_urls != NULL) if (arg_urls != NULL)
{ {
for (i = 0; i < g_strv_length(arg_urls); i++) guint i;
for (i = 0; i < g_strv_length (arg_urls); i++)
{ {
buf = g_strdup_printf ("%s %s", i==0? "server" : "newserver", arg_urls[i]); buf = g_strdup_printf ("%s %s", i==0? "server" : "newserver", arg_urls[i]);
handle_command (sess, buf, FALSE); handle_command (sess, buf, FALSE);
@ -1012,7 +1013,7 @@ main (int argc, char *argv[])
int i; int i;
int ret; int ret;
srand (time (0)); /* CL: do this only once! */ srand ((unsigned int) time (NULL)); /* CL: do this only once! */
/* We must check for the config dir parameter, otherwise load_config() will behave incorrectly. /* We must check for the config dir parameter, otherwise load_config() will behave incorrectly.
* load_config() must come before fe_args() because fe_args() calls gtk_init() which needs to * load_config() must come before fe_args() because fe_args() calls gtk_init() which needs to

View File

@ -682,7 +682,8 @@ inbound_nameslist (server *serv, char *chan, char *names,
char **name_list; char **name_list;
char *host, *nopre_name; char *host, *nopre_name;
char name[NICKLEN]; char name[NICKLEN];
int i, offset; int i;
size_t offset;
sess = find_channel (serv, chan); sess = find_channel (serv, chan);
if (!sess) if (!sess)

View File

@ -677,10 +677,10 @@ handle_mode (server * serv, char *word[], char *word_eol[],
char *argstr; char *argstr;
char sign; char sign;
int len; int len;
int arg; size_t arg;
int i, num_args; size_t i, num_args;
int num_modes; int num_modes;
int offset = 3; size_t offset = 3;
int all_modes_have_args = FALSE; int all_modes_have_args = FALSE;
int using_front_tab = FALSE; int using_front_tab = FALSE;
mode_run mr; mode_run mr;
@ -762,7 +762,7 @@ handle_mode (server * serv, char *word[], char *word_eol[],
break; break;
default: default:
argstr = ""; argstr = "";
if ((all_modes_have_args || mode_has_arg (serv, sign, *modes)) && arg < (num_args+1)) if ((all_modes_have_args || mode_has_arg (serv, sign, *modes)) && arg < (num_args + 1))
{ {
arg++; arg++;
argstr = word[arg + offset]; argstr = word[arg + offset];

View File

@ -1355,8 +1355,8 @@ process_named_servermsg (session *sess, char *buf, char *rawname, char *word_eol
/* Returns the timezone offset. This should be the same as the variable /* Returns the timezone offset. This should be the same as the variable
* "timezone" in time.h, but *BSD doesn't have it. * "timezone" in time.h, but *BSD doesn't have it.
*/ */
static int static time_t
get_timezone(void) get_timezone (void)
{ {
struct tm tm_utc, tm_local; struct tm tm_utc, tm_local;
time_t t, time_utc, time_local; time_t t, time_utc, time_local;

View File

@ -142,7 +142,7 @@ tab_scroll_left_up_clicked (GtkWidget *widget, chanview *cv)
gfloat new_value; gfloat new_value;
GtkWidget *inner; GtkWidget *inner;
GdkWindow *parent_win; GdkWindow *parent_win;
gfloat i; gdouble i;
inner = ((tabview *)cv)->inner; inner = ((tabview *)cv)->inner;
parent_win = gtk_widget_get_window (gtk_widget_get_parent (inner)); parent_win = gtk_widget_get_window (gtk_widget_get_parent (inner));
@ -191,7 +191,7 @@ tab_scroll_right_down_clicked (GtkWidget *widget, chanview *cv)
gfloat new_value; gfloat new_value;
GtkWidget *inner; GtkWidget *inner;
GdkWindow *parent_win; GdkWindow *parent_win;
gfloat i; gdouble i;
inner = ((tabview *)cv)->inner; inner = ((tabview *)cv)->inner;
parent_win = gtk_widget_get_window (gtk_widget_get_parent (inner)); parent_win = gtk_widget_get_window (gtk_widget_get_parent (inner));

View File

@ -336,7 +336,7 @@ custom_list_get_iter (GtkTreeModel * tree_model,
gint n; gint n;
n = gtk_tree_path_get_indices (path)[0]; n = gtk_tree_path_get_indices (path)[0];
if (n >= custom_list->num_rows || n < 0) if (n < 0 || (guint) n >= custom_list->num_rows)
return FALSE; return FALSE;
record = custom_list->rows[n]; record = custom_list->rows[n];
@ -533,7 +533,7 @@ custom_list_iter_nth_child (GtkTreeModel * tree_model,
return FALSE; return FALSE;
/* special case: if parent == NULL, set iter to n-th top-level row */ /* special case: if parent == NULL, set iter to n-th top-level row */
if (n >= custom_list->num_rows) if (n < 0 || (guint) n >= custom_list->num_rows)
return FALSE; return FALSE;
iter->user_data = custom_list->rows[n]; iter->user_data = custom_list->rows[n];

View File

@ -77,10 +77,10 @@ struct _CustomList
{ {
GObject parent; GObject parent;
guint num_rows; /* number of rows that we have used */ guint num_rows; /* number of rows that we have used */
guint num_alloc; /* number of rows allocated */ guint num_alloc; /* number of rows allocated */
chanlistrow **rows; /* a dynamically allocated array of pointers to the chanlistrow **rows; /* a dynamically allocated array of pointers to the
* CustomRecord structure for each row */ * CustomRecord structure for each row */
gint n_columns; gint n_columns;
GType column_types[CUSTOM_LIST_N_COLUMNS]; GType column_types[CUSTOM_LIST_N_COLUMNS];

View File

@ -92,9 +92,9 @@ struct server_gui
guint chanlist_channels_shown_count; /* total number of displayed guint chanlist_channels_shown_count; /* total number of displayed
channels */ channels */
int chanlist_maxusers; guint32 chanlist_maxusers;
int chanlist_minusers; guint32 chanlist_minusers;
int chanlist_minusers_downloaded; /* used by LIST IRC command */ guint32 chanlist_minusers_downloaded; /* used by LIST IRC command */
int chanlist_search_type; /* 0=simple 1=pattern/wildcard 2=regexp */ int chanlist_search_type; /* 0=simple 1=pattern/wildcard 2=regexp */
gboolean chanlist_caption_is_stale; gboolean chanlist_caption_is_stale;
}; };

View File

@ -1600,7 +1600,7 @@ key_action_tab_comp (GtkWidget *t, GdkEventKey *entry, char *d1, char *d2,
old_gcomp.elen = elen; old_gcomp.elen = elen;
/* Get the first nick and put out the data for future nickcompletes */ /* Get the first nick and put out the data for future nickcompletes */
if (prefs.hex_completion_amount && g_list_length (list) <= prefs.hex_completion_amount) if (prefs.hex_completion_amount > 0 && g_list_length (list) <= (guint) prefs.hex_completion_amount)
{ {
g_free(result); g_free(result);
result = (char*)list->data; result = (char*)list->data;

View File

@ -151,7 +151,7 @@ joind_show_dialog (server *serv)
image1 = gtk_image_new_from_stock (GTK_STOCK_NETWORK, GTK_ICON_SIZE_LARGE_TOOLBAR); image1 = gtk_image_new_from_stock (GTK_STOCK_NETWORK, GTK_ICON_SIZE_LARGE_TOOLBAR);
gtk_widget_show (image1); gtk_widget_show (image1);
gtk_box_pack_start (GTK_BOX (hbox1), image1, FALSE, TRUE, 24); gtk_box_pack_start (GTK_BOX (hbox1), image1, FALSE, TRUE, 24);
gtk_misc_set_alignment (GTK_MISC (image1), 0.5, 0.06); gtk_misc_set_alignment (GTK_MISC (image1), 0.5f, 0.06f);
vbox2 = gtk_vbox_new (FALSE, 10); vbox2 = gtk_vbox_new (FALSE, 10);
gtk_container_set_border_width (GTK_CONTAINER (vbox2), 6); gtk_container_set_border_width (GTK_CONTAINER (vbox2), 6);

View File

@ -557,7 +557,7 @@ static int
mg_progressbar_update (GtkWidget *bar) mg_progressbar_update (GtkWidget *bar)
{ {
static int type = 0; static int type = 0;
static float pos = 0; static gdouble pos = 0;
pos += 0.05; pos += 0.05;
if (pos >= 0.99) if (pos >= 0.99)

View File

@ -146,7 +146,7 @@ fe_add_rawlog (server *serv, char *text, int len, int outbound)
{ {
char **split_text; char **split_text;
char *new_text; char *new_text;
int i; size_t i;
if (!serv->gui->rawlog_window) if (!serv->gui->rawlog_window)
return; return;