summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>2023-10-23 22:33:17 +0300
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-10-24 22:31:26 +0300
commitbc8f7abe97159ee68106e5a99d5fc242cd01f150 (patch)
tree6fd65e73c07fd1d44b51f58da5425fed1a4de8bc
parent48cf49d31994ff97b33c4044e618560ec84d35fb (diff)
downloadlinux-bc8f7abe97159ee68106e5a99d5fc242cd01f150.tar.xz
ACPI: sysfs: Clean up create_pnp_modalias() and create_of_modalias()
'modalias' is only written with snprintf() and it is already guaranteed to be nul-terminated, so remove the unneeded (but harmless) writes of a trailing '\0' to it. Also snprintf() never returns negative values, so remove redundant (but harmless) checks for it. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> [ rjw: Merge two patches into one, combine changelogs, add subject ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/device_sysfs.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index a34d8578b3da..991583e2ee5f 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -168,8 +168,6 @@ static int create_pnp_modalias(const struct acpi_device *acpi_dev, char *modalia
continue;
count = snprintf(&modalias[len], size, "%s:", id->id);
- if (count < 0)
- return -EINVAL;
if (count >= size)
return -ENOMEM;
@@ -177,7 +175,7 @@ static int create_pnp_modalias(const struct acpi_device *acpi_dev, char *modalia
len += count;
size -= count;
}
- modalias[len] = '\0';
+
return len;
}
@@ -228,8 +226,6 @@ static int create_of_modalias(const struct acpi_device *acpi_dev, char *modalias
for (i = 0; i < nval; i++, obj++) {
count = snprintf(&modalias[len], size, "C%s",
obj->string.pointer);
- if (count < 0)
- return -EINVAL;
if (count >= size)
return -ENOMEM;
@@ -237,7 +233,7 @@ static int create_of_modalias(const struct acpi_device *acpi_dev, char *modalias
len += count;
size -= count;
}
- modalias[len] = '\0';
+
return len;
}