Warning cleanup

- ignoring const
- declarations after statements
- some C files didnt include own headers (risking them getting out of sync)

Closes #1064
This commit is contained in:
Campbell Barton
2014-07-19 13:36:13 +10:00
committed by TingPing
parent 9fb4eb5107
commit f83d78dd28
17 changed files with 29 additions and 21 deletions

View File

@@ -414,6 +414,9 @@ Util_BuildEOLList(char *word[])
PyObject *list;
int listsize = 31;
int i;
char *accum = NULL;
char *last = NULL;
/* Find the last valid array member; there may be intermediate NULLs that
* would otherwise cause us to drop some members. */
while (listsize > 0 &&
@@ -424,10 +427,9 @@ Util_BuildEOLList(char *word[])
PyErr_Print();
return NULL;
}
char *accum = NULL;
char *last = NULL;
for (i = listsize; i > 0; i--) {
char *part = word[i];
PyObject *uni_part;
if (accum == NULL) {
accum = g_strdup (part);
} else if (part != NULL && part[0] != 0) {
@@ -443,7 +445,7 @@ Util_BuildEOLList(char *word[])
return NULL;
}
}
PyObject *uni_part = PyUnicode_FromString(accum);
uni_part = PyUnicode_FromString(accum);
PyList_SetItem(list, i - 1, uni_part);
}

View File

@@ -53,8 +53,9 @@ void get_hwmon_chip_name(char *name)
void get_hwmon_temp(unsigned int *value, unsigned int *sensor)
{
char buffer[bsize];
FILE *fp;
snprintf(buffer, bsize, "/sys/class/hwmon/hwmon0/device/temp%i_input", *sensor);
FILE *fp = fopen(buffer, "r");
fp = fopen(buffer, "r");
if(fp != NULL) {
if(fgets(buffer, bsize, fp) != NULL)
*value = atoi(buffer);

View File

@@ -32,12 +32,12 @@ float percentage(unsigned long long *free, unsigned long long *total)
char *pretty_freespace(const char *desc, unsigned long long *free_k, unsigned long long *total_k)
{
char *result, **quantity;
char *quantities[] = { "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", 0 };
char *result, **quantity;
double free_space, total_space;
free_space = *free_k;
total_space = *total_k;
result = malloc(bsize * sizeof(char));
char *quantities[] = { "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", 0 };
if (total_space == 0)
{
snprintf(result, bsize, "%s: none", desc);

View File

@@ -34,6 +34,7 @@
#include "match.h"
#include "hwmon.h"
#include "xsys.h"
#include "parse.h"
int xs_parse_cpu(char *model, char *vendor, double *freq, char *cache, unsigned int *count)
{

View File

@@ -115,9 +115,10 @@ void pci_find_fullname(char *fullname, char *vendor, char *device)
char devicename[bsize/2] = "";
char *position;
int cardfound = 0;
FILE *fp;
sysinfo_get_pciids (buffer);
FILE *fp = fopen (buffer, "r");
fp = fopen (buffer, "r");
if(fp == NULL) {
snprintf(fullname, bsize, "%s:%s", vendor, device);

View File

@@ -878,11 +878,11 @@ sysinfo_cb (char *word[], char *word_eol[], void *userdata)
int
hexchat_plugin_init (hexchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
{
char buffer[bsize];
ph = plugin_handle;
*plugin_name = name;
*plugin_desc = desc;
*plugin_version = version;
char buffer[bsize];
hexchat_hook_command (ph, "SYSINFO", HEXCHAT_PRI_NORM, sysinfo_cb, sysinfo_help, NULL);
hexchat_hook_command (ph, "NETDATA", HEXCHAT_PRI_NORM, netdata_cb, NULL, NULL);