1
0
mirror of https://github.com/anope/anope.git synced 2026-07-02 14:53:13 +02:00

Fixed some warnings found by cppcheck

This commit is contained in:
Adam
2010-12-07 17:01:58 -05:00
parent c5fc11f5fe
commit 2b7dd6c2a0
10 changed files with 23 additions and 9 deletions
+3 -1
View File
@@ -161,6 +161,8 @@ void write_version(FILE * fd)
char buf[1024];
short until_eof = 0;
if (!fdin)
return;
while (fgets(buf, 1023, fdin)) {
strip(buf);
@@ -173,7 +175,7 @@ void write_version(FILE * fd)
if (!strcmp(buf, "cat >version.h <<EOF"))
until_eof = 1;
}
fclose(fdin);
}
void parse_line(FILE * fd, char *line)
+4
View File
@@ -77,10 +77,12 @@ int read_index_file()
numstrings++;
if (!(stringnames = calloc(sizeof(char *), numstrings))) {
perror("calloc(stringnames)");
fclose(f);
return -1;
}
if (!(strings = calloc(sizeof(char *), numstrings))) {
perror("calloc(strings)");
fclose(f);
return -1;
}
fseek(f, 0, SEEK_SET);
@@ -90,6 +92,7 @@ int read_index_file()
buf[strlen(buf)-1] = '\0';
if (!(stringnames[i++] = anopeStrDup(buf))) {
perror("strdup()");
fclose(f);
return -1;
}
}
@@ -201,6 +204,7 @@ int main(int ac, char **av)
}
if (!(out = fopen(outfile, "wb"))) {
perror(outfile);
fclose(in);
return 1;
}
+4 -2
View File
@@ -926,7 +926,9 @@ int read_config(int reload)
perror("Can't open " SERVICES_CONF);
else
alog("Can't open %s", SERVICES_CONF);
#ifndef NOT_MAIN
}
#endif
return 0;
}
while (fgets(buf, sizeof(buf), config)) {
@@ -1246,7 +1248,7 @@ int read_config(int reload)
if (s) {
RootNumber++;
ServicesRoots =
realloc(ServicesRoots, sizeof(char *) * RootNumber);
srealloc(ServicesRoots, sizeof(char *) * RootNumber);
ServicesRoots[RootNumber - 1] = sstrdup(s);
}
} while ((s = strtok(NULL, " ")));
@@ -1266,7 +1268,7 @@ int read_config(int reload)
do {
if (s) {
NumUlines++;
Ulines = realloc(Ulines, sizeof(char *) * NumUlines);
Ulines = srealloc(Ulines, sizeof(char *) * NumUlines);
Ulines[NumUlines - 1] = sstrdup(s);
}
} while ((s = strtok(NULL, " ")));
+1 -1
View File
@@ -1221,7 +1221,7 @@ char **buildStringList(char *src, int *number)
do {
if (s) {
i++;
list = realloc(list, sizeof(char *) * i);
list = srealloc(list, sizeof(char *) * i);
list[i - 1] = sstrdup(s);
}
} while ((s = strtok(NULL, " ")));
+3 -1
View File
@@ -537,7 +537,7 @@ int moduleCopyFile(char *name, char *output)
int ch;
FILE *source, *target;
int srcfp;
char input[4096];
char input[4096] = "";
int len;
strncpy(input, MODULE_PATH, 4095); /* Get full path with module extension */
@@ -562,6 +562,7 @@ int moduleCopyFile(char *name, char *output)
*/
#ifndef _WIN32
if ((source = fopen(input, "r")) == NULL) {
close(srcfp);
#else
if ((source = fopen(input, "rb")) == NULL) {
#endif
@@ -572,6 +573,7 @@ int moduleCopyFile(char *name, char *output)
#else
if ((target = fopen(output, "wb")) == NULL) {
#endif
fclose(source);
return MOD_ERR_FILE_IO;
}
while ((ch = fgetc(source)) != EOF) {
@@ -232,7 +232,7 @@ void WriteNick(char *line)
}
}
}
else if (!strcmp(tok, "SO"))
else if (na && !strcmp(tok, "SO"))
{
tok = strtok(NULL, " ");
na->nc->flags |= NI_SERVICES_OPER;
+1
View File
@@ -127,6 +127,7 @@ int mLoadData(void)
free(name);
}
}
fclose(in);
}
return ret;
}
+2 -1
View File
@@ -86,15 +86,16 @@ int __stdcall mysql_LoadFromFile(char *file)
add_line(&query, line);
if (mysql_real_query(mysql, query, strlen(query))) {
free(query);
fclose(fd);
return 0;
}
free(query);
query = NULL;
}
else
add_line(&query, line);
}
fclose(fd);
return 1;
}
+2 -1
View File
@@ -1384,7 +1384,7 @@ void insert_core(NickCore * nc)
/*************************************************************************/
void insert_requestnick(NickRequest * nr)
{
int index = HASH(nr->nick);
int index;
if (!nr) {
if (debug) {
alog("debug: insert_requestnick called with NULL values");
@@ -1392,6 +1392,7 @@ void insert_requestnick(NickRequest * nr)
return;
}
index = HASH(nr->nick);
nr->prev = NULL;
nr->next = nrlists[index];
+2 -1
View File
@@ -8,9 +8,10 @@ VERSION_MAJOR="1"
VERSION_MINOR="8"
VERSION_PATCH="5"
VERSION_EXTRA="-git"
VERSION_BUILD="3046"
VERSION_BUILD="3047"
# $Log$ # Changes since 1.8.5 Release
#Revision 3047 - Fixed some warnings found by cppcheck
#Revision 3046 - Fixed bug #1202 - Made Anope aware of plexus3's channel mode +z
#Revision 3045 - Fixed some improper english in the HOST_GROUP language strings
#Revision 3044 - Fixed a potential crash from accessing invalid memory after unbanning people when checking whether a host is akick stuck. Fixes /cs unban not reapplying stuck ban masks.