From a9f0290a6754a475eb95818dd38dc401370da071 Mon Sep 17 00:00:00 2001 From: liuchao173 <55137861+liuchao173@users.noreply.github.com> Date: Mon, 23 Aug 2021 19:40:41 +0800 Subject: [PATCH] fix opendir fails in check_platform_device Reference: https://github.com/Irqbalance/irqbalance/commit/a9f0290a6754a475eb95818dd38dc401370da071 Conflict: NA When irq name does not contain spaces, savedptr is an empty string and irq_fullname will have a extra space at the end like "LNRO0005:00 ". So opendir in check_platform_device will fail, and irqbalance prints log: "No directory /sys/devices/platform/LNRO0005:00 /: No such file or directory" --- procinterrupts.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/procinterrupts.c b/procinterrupts.c index e372671..9015177 100644 --- a/procinterrupts.c +++ b/procinterrupts.c @@ -178,10 +178,12 @@ void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq) } #ifdef AARCH64 - snprintf(irq_fullname, PATH_MAX, "%s %s", last_token, savedptr); - tmp = strchr(irq_fullname, '\n'); - if (tmp) - *tmp = 0; + if (strlen(savedptr) > 0) { + snprintf(irq_fullname, PATH_MAX, "%s %s", last_token, savedptr); + tmp = strchr(irq_fullname, '\n'); + if (tmp) + *tmp = 0; + } #else snprintf(irq_fullname, PATH_MAX, "%s", last_token); #endif -- 2.33.0