irqbalance/make-the-return-value-of-getline-handled-correct.patch

130 lines
3.6 KiB
Diff
Raw Normal View History

2020-07-03 17:09:39 +08:00
From 735c0241afa78459eefb7eb9a60fe0b7b0029430 Mon Sep 17 00:00:00 2001
From: Yunfeng Ye <yeyunfeng@huawei.com>
Date: Wed, 18 Sep 2019 22:26:44 +0800
Subject: [PATCH 14/53] make the return value of getline() handled correct
2019-11-06 19:34:16 +08:00
2020-07-03 17:09:39 +08:00
getline() will return -1 when fail, so make the return value handle
correct.
2019-11-06 19:34:16 +08:00
2020-07-03 17:09:39 +08:00
Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
2019-11-06 19:34:16 +08:00
---
activate.c | 2 +-
2020-07-03 17:09:39 +08:00
cputree.c | 8 ++++----
2019-11-06 19:34:16 +08:00
procinterrupts.c | 12 ++++++------
2020-07-03 17:09:39 +08:00
3 files changed, 11 insertions(+), 11 deletions(-)
2019-11-06 19:34:16 +08:00
diff --git a/activate.c b/activate.c
2020-07-03 17:09:39 +08:00
index 8fd9bde..2812976 100644
2019-11-06 19:34:16 +08:00
--- a/activate.c
+++ b/activate.c
2020-07-03 17:09:39 +08:00
@@ -44,7 +44,7 @@ static int check_affinity(struct irq_info *info, cpumask_t applied_mask)
2019-11-06 19:34:16 +08:00
file = fopen(buf, "r");
if (!file)
return 1;
- if (getline(&line, &size, file)==0) {
+ if (getline(&line, &size, file)<=0) {
free(line);
fclose(file);
return 1;
diff --git a/cputree.c b/cputree.c
2020-07-03 17:09:39 +08:00
index 5551784..91c6111 100644
2019-11-06 19:34:16 +08:00
--- a/cputree.c
+++ b/cputree.c
2020-07-03 17:09:39 +08:00
@@ -278,7 +278,7 @@ static void do_one_cpu(char *path)
if (file) {
char *line = NULL;
size_t size = 0;
- if (getline(&line, &size, file)==0)
+ if (getline(&line, &size, file)<=0)
return;
fclose(file);
if (line && line[0]=='0') {
@@ -323,7 +323,7 @@ static void do_one_cpu(char *path)
2019-11-06 19:34:16 +08:00
if (file) {
char *line = NULL;
size_t size = 0;
- if (getline(&line, &size, file))
+ if (getline(&line, &size, file) > 0)
cpumask_parse_user(line, strlen(line), package_mask);
fclose(file);
free(line);
2020-07-03 17:09:39 +08:00
@@ -335,7 +335,7 @@ static void do_one_cpu(char *path)
2019-11-06 19:34:16 +08:00
if (file) {
char *line = NULL;
size_t size = 0;
- if (getline(&line, &size, file))
+ if (getline(&line, &size, file) > 0)
packageid = strtoul(line, NULL, 10);
fclose(file);
free(line);
2020-07-03 17:09:39 +08:00
@@ -368,7 +368,7 @@ static void do_one_cpu(char *path)
2019-11-06 19:34:16 +08:00
if (file) {
char *line = NULL;
size_t size = 0;
- if (getline(&line, &size, file))
+ if (getline(&line, &size, file) > 0)
cpumask_parse_user(line, strlen(line), cache_mask);
fclose(file);
free(line);
diff --git a/procinterrupts.c b/procinterrupts.c
2020-07-03 17:09:39 +08:00
index 3898b10..03b4593 100644
2019-11-06 19:34:16 +08:00
--- a/procinterrupts.c
+++ b/procinterrupts.c
2020-07-03 17:09:39 +08:00
@@ -161,7 +161,7 @@ GList* collect_full_irq_list()
2019-11-06 19:34:16 +08:00
return NULL;
/* first line is the header we don't need; nuke it */
- if (getline(&line, &size, file)==0) {
+ if (getline(&line, &size, file)<=0) {
free(line);
fclose(file);
return NULL;
2020-07-03 17:09:39 +08:00
@@ -174,7 +174,7 @@ GList* collect_full_irq_list()
2019-11-06 19:34:16 +08:00
char *c;
char *savedline = NULL;
- if (getline(&line, &size, file)==0)
+ if (getline(&line, &size, file)<=0)
break;
/* lines with letters in front are special, like NMI count. Ignore */
2020-07-03 17:09:39 +08:00
@@ -248,7 +248,7 @@ void parse_proc_interrupts(void)
2019-11-06 19:34:16 +08:00
return;
/* first line is the header we don't need; nuke it */
- if (getline(&line, &size, file)==0) {
+ if (getline(&line, &size, file)<=0) {
free(line);
fclose(file);
return;
2020-07-03 17:09:39 +08:00
@@ -262,7 +262,7 @@ void parse_proc_interrupts(void)
2020-03-24 11:44:22 +08:00
struct irq_info *info;
2019-11-06 19:34:16 +08:00
char savedline[1024];
- if (getline(&line, &size, file)==0)
+ if (getline(&line, &size, file)<=0)
break;
if (!proc_int_has_msi)
2020-07-03 17:09:39 +08:00
@@ -444,7 +444,7 @@ void parse_proc_stat(void)
2019-11-06 19:34:16 +08:00
}
/* first line is the header we don't need; nuke it */
- if (getline(&line, &size, file)==0) {
+ if (getline(&line, &size, file)<=0) {
free(line);
log(TO_ALL, LOG_WARNING, "WARNING read /proc/stat. balancing is broken\n");
fclose(file);
2020-07-03 17:09:39 +08:00
@@ -453,7 +453,7 @@ void parse_proc_stat(void)
2019-11-06 19:34:16 +08:00
cpucount = 0;
while (!feof(file)) {
- if (getline(&line, &size, file)==0)
+ if (getline(&line, &size, file)<=0)
break;
if (!strstr(line, "cpu"))
--
2020-07-03 17:09:39 +08:00
2.23.0
2019-11-06 19:34:16 +08:00