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

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86: think-lmi: Use strreplace() to replace a character by nul

We can replace
p = strchrnul(str, '$OLD');
*p = '\0';
with
strreplace(str, '$OLD', '\0');
that does the compatible modification without a need of the temporary variable.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230918135116.1248560-2-andriy.shevchenko@linux.intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

authored by

Andy Shevchenko and committed by
Hans de Goede
6cb9c863 e6211980

+4 -15
+4 -15
drivers/platform/x86/think-lmi.c
··· 198 198 static struct class *fw_attr_class; 199 199 static DEFINE_MUTEX(tlmi_mutex); 200 200 201 - /* ------ Utility functions ------------*/ 202 - /* Strip out CR if one is present */ 203 - static void strip_cr(char *str) 204 - { 205 - char *p = strchrnul(str, '\n'); 206 - *p = '\0'; 207 - } 208 - 209 201 /* Convert BIOS WMI error string to suitable error code */ 210 202 static int tlmi_errstr_to_err(const char *errstr) 211 203 { ··· 403 411 404 412 strscpy(setting->password, buf, setting->maxlen); 405 413 /* Strip out CR if one is present, setting password won't work if it is present */ 406 - strip_cr(setting->password); 414 + strreplace(setting->password, '\n', '\0'); 407 415 return count; 408 416 } 409 417 ··· 913 921 static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 914 922 { 915 923 struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj); 916 - char *item, *value, *p; 924 + char *item, *value; 917 925 int ret; 918 926 919 927 ret = tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID); ··· 926 934 ret = -EINVAL; 927 935 else { 928 936 /* On Workstations remove the Options part after the value */ 929 - p = strchrnul(value, ';'); 930 - *p = '\0'; 937 + strreplace(value, ';', '\0'); 931 938 ret = sysfs_emit(buf, "%s\n", value + 1); 932 939 } 933 940 kfree(item); ··· 1531 1540 for (i = 0; i < TLMI_SETTINGS_COUNT; ++i) { 1532 1541 struct tlmi_attr_setting *setting; 1533 1542 char *item = NULL; 1534 - char *p; 1535 1543 1536 1544 tlmi_priv.setting[i] = NULL; 1537 1545 ret = tlmi_setting(i, &item, LENOVO_BIOS_SETTING_GUID); ··· 1547 1557 strreplace(item, '/', '\\'); 1548 1558 1549 1559 /* Remove the value part */ 1550 - p = strchrnul(item, ','); 1551 - *p = '\0'; 1560 + strreplace(item, ',', '\0'); 1552 1561 1553 1562 /* Create a setting entry */ 1554 1563 setting = kzalloc(sizeof(*setting), GFP_KERNEL);