Skip to content

Commit bc8f7ab

Browse files
tititiou36rafaeljw
authored andcommitted
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 <[email protected]> [ rjw: Merge two patches into one, combine changelogs, add subject ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 48cf49d commit bc8f7ab

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

drivers/acpi/device_sysfs.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,14 @@ static int create_pnp_modalias(const struct acpi_device *acpi_dev, char *modalia
168168
continue;
169169

170170
count = snprintf(&modalias[len], size, "%s:", id->id);
171-
if (count < 0)
172-
return -EINVAL;
173171

174172
if (count >= size)
175173
return -ENOMEM;
176174

177175
len += count;
178176
size -= count;
179177
}
180-
modalias[len] = '\0';
178+
181179
return len;
182180
}
183181

@@ -228,16 +226,14 @@ static int create_of_modalias(const struct acpi_device *acpi_dev, char *modalias
228226
for (i = 0; i < nval; i++, obj++) {
229227
count = snprintf(&modalias[len], size, "C%s",
230228
obj->string.pointer);
231-
if (count < 0)
232-
return -EINVAL;
233229

234230
if (count >= size)
235231
return -ENOMEM;
236232

237233
len += count;
238234
size -= count;
239235
}
240-
modalias[len] = '\0';
236+
241237
return len;
242238
}
243239

0 commit comments

Comments
 (0)