mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 02:55:12 +00:00
match signedness and format when scanning into variables
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1058 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
ac2dd1b34b
commit
418b3d62e0
22
src/conky.c
22
src/conky.c
@ -804,7 +804,7 @@ static char *scan_graph(const char *args, int *w, int *h,
|
||||
*scale = 0;
|
||||
/* graph's argument is either height or height,width */
|
||||
if (args) {
|
||||
if (sscanf(args, "%d,%d %x %x %i", h, w, first_colour, last_colour,
|
||||
if (sscanf(args, "%d,%d %x %x %u", h, w, first_colour, last_colour,
|
||||
scale) == 5) {
|
||||
return NULL;
|
||||
}
|
||||
@ -812,7 +812,7 @@ static char *scan_graph(const char *args, int *w, int *h,
|
||||
if (sscanf(args, "%d,%d %x %x", h, w, first_colour, last_colour) == 4) {
|
||||
return NULL;
|
||||
}
|
||||
if (sscanf(args, "%63s %d,%d %x %x %i", buf, h, w, first_colour,
|
||||
if (sscanf(args, "%63s %d,%d %x %x %u", buf, h, w, first_colour,
|
||||
last_colour, scale) == 6) {
|
||||
return strdup(buf);
|
||||
}
|
||||
@ -824,14 +824,14 @@ static char *scan_graph(const char *args, int *w, int *h,
|
||||
buf[0] = '\0';
|
||||
*h = 25;
|
||||
*w = 0;
|
||||
if (sscanf(args, "%x %x %i", first_colour, last_colour, scale) == 3) {
|
||||
if (sscanf(args, "%x %x %u", first_colour, last_colour, scale) == 3) {
|
||||
return NULL;
|
||||
}
|
||||
*scale = 0;
|
||||
if (sscanf(args, "%x %x", first_colour, last_colour) == 2) {
|
||||
return NULL;
|
||||
}
|
||||
if (sscanf(args, "%63s %x %x %i", buf, first_colour, last_colour,
|
||||
if (sscanf(args, "%63s %x %x %u", buf, first_colour, last_colour,
|
||||
scale) == 4) {
|
||||
return strdup(buf);
|
||||
}
|
||||
@ -842,14 +842,14 @@ static char *scan_graph(const char *args, int *w, int *h,
|
||||
buf[0] = '\0';
|
||||
*first_colour = 0;
|
||||
*last_colour = 0;
|
||||
if (sscanf(args, "%d,%d %i", h, w, scale) == 3) {
|
||||
if (sscanf(args, "%d,%d %u", h, w, scale) == 3) {
|
||||
return NULL;
|
||||
}
|
||||
*scale = 0;
|
||||
if (sscanf(args, "%d,%d", h, w) == 2) {
|
||||
return NULL;
|
||||
}
|
||||
if (sscanf(args, "%63s %d,%d %i", buf, h, w, scale) < 4) {
|
||||
if (sscanf(args, "%63s %d,%d %u", buf, h, w, scale) < 4) {
|
||||
*scale = 0;
|
||||
//TODO: check the return value and throw an error?
|
||||
sscanf(args, "%63s %d,%d", buf, h, w);
|
||||
@ -2708,7 +2708,7 @@ static struct text_object *construct_text_object(const char *s,
|
||||
END OBJ(execgraph, 0)
|
||||
obj->data.s = strdup(arg ? arg : "");
|
||||
END OBJ(execibar, 0)
|
||||
unsigned int n;
|
||||
int n;
|
||||
|
||||
if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
|
||||
char buf[256];
|
||||
@ -2721,7 +2721,7 @@ static struct text_object *construct_text_object(const char *s,
|
||||
obj->data.execi.cmd = strdup(arg + n);
|
||||
}
|
||||
END OBJ(execigraph, 0)
|
||||
unsigned int n;
|
||||
int n;
|
||||
|
||||
if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
|
||||
char buf[256];
|
||||
@ -2734,7 +2734,7 @@ static struct text_object *construct_text_object(const char *s,
|
||||
obj->data.execi.cmd = strdup(arg + n);
|
||||
}
|
||||
END OBJ(execi, 0)
|
||||
unsigned int n;
|
||||
int n;
|
||||
|
||||
if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
|
||||
char buf[256];
|
||||
@ -2748,7 +2748,7 @@ static struct text_object *construct_text_object(const char *s,
|
||||
obj->data.execi.buffer = malloc(text_buffer_size);
|
||||
}
|
||||
END OBJ(execpi, 0)
|
||||
unsigned int n;
|
||||
int n;
|
||||
|
||||
if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
|
||||
char buf[256];
|
||||
@ -2762,7 +2762,7 @@ static struct text_object *construct_text_object(const char *s,
|
||||
obj->data.execi.buffer = malloc(text_buffer_size);
|
||||
}
|
||||
END OBJ(texeci, 0)
|
||||
unsigned int n;
|
||||
int n;
|
||||
|
||||
if (!arg || sscanf(arg, "%f %n", &obj->data.texeci.interval, &n) <= 0) {
|
||||
char buf[256];
|
||||
|
@ -588,7 +588,7 @@ char *get_disk_protect_queue(char *disk);
|
||||
void get_cpu_count(void);
|
||||
|
||||
struct ibm_acpi_struct {
|
||||
unsigned int temps[8];
|
||||
int temps[8];
|
||||
};
|
||||
|
||||
struct ibm_acpi_struct ibm_acpi;
|
||||
|
17
src/linux.c
17
src/linux.c
@ -524,7 +524,7 @@ void update_total_processes(void)
|
||||
info.procs = 0;
|
||||
return;
|
||||
}
|
||||
fscanf(fp, "%*f %*f %*f %*d/%hd", &info.procs);
|
||||
fscanf(fp, "%*f %*f %*f %*d/%hu", &info.procs);
|
||||
fclose(fp);
|
||||
}
|
||||
info.mask |= (1 << INFO_PROCS);
|
||||
@ -1783,7 +1783,8 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
|
||||
}
|
||||
|
||||
if (apm_bat_fp[idx] != NULL) {
|
||||
int ac, status, flag, life;
|
||||
unsigned int ac, status, flag;
|
||||
int life;
|
||||
|
||||
fscanf(apm_bat_fp[idx], "%*s %*s %*x %x %x %x %d%%",
|
||||
&ac, &status, &flag, &life);
|
||||
@ -1961,7 +1962,8 @@ void get_powerbook_batt_info(char *buf, size_t n, int i)
|
||||
static int rep = 0;
|
||||
const char *batt_path = PMU_PATH "/battery_0";
|
||||
const char *info_path = PMU_PATH "/info";
|
||||
int flags, charge, max_charge, ac = -1;
|
||||
unsigned int flags;
|
||||
int charge, max_charge, ac = -1;
|
||||
long time = -1;
|
||||
|
||||
/* don't update battery too often */
|
||||
@ -2078,7 +2080,8 @@ void update_diskio(void)
|
||||
static int rep = 0;
|
||||
|
||||
char buf[512], devbuf[64];
|
||||
int major, minor, i;
|
||||
int i;
|
||||
unsigned int major, minor;
|
||||
unsigned int current = 0;
|
||||
unsigned int current_read = 0;
|
||||
unsigned int current_write = 0;
|
||||
@ -2221,7 +2224,7 @@ void get_ibm_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
|
||||
if (fgets(line, 255, fp) == NULL) {
|
||||
break;
|
||||
}
|
||||
if (sscanf(line, "speed: %d", &speed)) {
|
||||
if (sscanf(line, "speed: %u", &speed)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2331,7 +2334,7 @@ void get_ibm_acpi_volume(char *p_client_buffer, size_t client_buffer_size)
|
||||
if (fgets(line, 255, fp) == NULL) {
|
||||
break;
|
||||
}
|
||||
if (sscanf(line, "level: %d", &read_vol)) {
|
||||
if (sscanf(line, "level: %u", &read_vol)) {
|
||||
vol = read_vol;
|
||||
continue;
|
||||
}
|
||||
@ -2384,7 +2387,7 @@ void get_ibm_acpi_brightness(char *p_client_buffer, size_t client_buffer_size)
|
||||
if (fgets(line, 255, fp) == NULL) {
|
||||
break;
|
||||
}
|
||||
if (sscanf(line, "level: %d", &brightness)) {
|
||||
if (sscanf(line, "level: %u", &brightness)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ static int process_parse_stat(struct process *process)
|
||||
|
||||
/* Extract cpu times from data in /proc filesystem */
|
||||
rc = sscanf(line, "%*s %s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %lu "
|
||||
"%lu %*s %*s %*s %d %*s %*s %*s %d %d", procname, &process->user_time,
|
||||
"%lu %*s %*s %*s %d %*s %*s %*s %u %u", procname, &process->user_time,
|
||||
&process->kernel_time, &nice_val, &process->vsize, &process->rss);
|
||||
if (rc < 5) {
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user