Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Christophe JAILLET and committed by
Rafael J. Wysocki
bc8f7abe 48cf49d3

+2 -6
+2 -6
drivers/acpi/device_sysfs.c
··· 168 168 continue; 169 169 170 170 count = snprintf(&modalias[len], size, "%s:", id->id); 171 - if (count < 0) 172 - return -EINVAL; 173 171 174 172 if (count >= size) 175 173 return -ENOMEM; ··· 175 177 len += count; 176 178 size -= count; 177 179 } 178 - modalias[len] = '\0'; 180 + 179 181 return len; 180 182 } 181 183 ··· 226 228 for (i = 0; i < nval; i++, obj++) { 227 229 count = snprintf(&modalias[len], size, "C%s", 228 230 obj->string.pointer); 229 - if (count < 0) 230 - return -EINVAL; 231 231 232 232 if (count >= size) 233 233 return -ENOMEM; ··· 233 237 len += count; 234 238 size -= count; 235 239 } 236 - modalias[len] = '\0'; 240 + 237 241 return len; 238 242 } 239 243