@@ -94,12 +94,12 @@ static int __init sr_init_by_name(const char *name, const char *voltdm)
struct omap_volt_data *volt_data;
static int i;
- if (!strncmp(name, "smartreflex_mpu_iva", 20) ||
- !strncmp(name, "smartreflex_mpu", 16))
+ if (!strncmp(name, "smartreflex_mpu_iva", 19) ||
+ !strncmp(name, "smartreflex_mpu", 15))
sr_data = &omap_sr_pdata[OMAP_SR_MPU];
- else if (!strncmp(name, "smartreflex_core", 17))
+ else if (!strncmp(name, "smartreflex_core", 16))
sr_data = &omap_sr_pdata[OMAP_SR_CORE];
- else if (!strncmp(name, "smartreflex_iva", 16))
+ else if (!strncmp(name, "smartreflex_iva", 15))
sr_data = &omap_sr_pdata[OMAP_SR_IVA];
if (!sr_data) {
@@ -4333,7 +4333,7 @@ static int __init amd64_edac_init(void)
return -EBUSY;
owner = edac_get_owner();
- if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR)))
+ if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR) - 1))
return -EBUSY;
if (!x86_match_cpu(amd64_cpuids))
@@ -759,7 +759,7 @@ static int __init i10nm_init(void)
return -EBUSY;
owner = edac_get_owner();
- if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR)))
+ if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR) - 1))
return -EBUSY;
if (cpu_feature_enabled(X86_FEATURE_HYPERVISOR))
@@ -1275,7 +1275,7 @@ static int __init igen6_init(void)
return -EBUSY;
owner = edac_get_owner();
- if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR)))
+ if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR) - 1))
return -EBUSY;
edac_op_state = EDAC_OPSTATE_NMI;
@@ -1532,7 +1532,7 @@ static int __init pnd2_init(void)
return -EBUSY;
owner = edac_get_owner();
- if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR)))
+ if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR) - 1))
return -EBUSY;
if (cpu_feature_enabled(X86_FEATURE_HYPERVISOR))
@@ -3638,7 +3638,7 @@ static int __init sbridge_init(void)
return -EBUSY;
owner = edac_get_owner();
- if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR)))
+ if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR) - 1))
return -EBUSY;
if (cpu_feature_enabled(X86_FEATURE_HYPERVISOR))
@@ -657,7 +657,7 @@ static int __init skx_init(void)
return -EBUSY;
owner = edac_get_owner();
- if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR)))
+ if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR) - 1))
return -EBUSY;
if (cpu_feature_enabled(X86_FEATURE_HYPERVISOR))
@@ -2968,7 +2968,7 @@ static void identify_by_eeprom(struct bttv *btv, unsigned char eeprom_data[256])
if (0 == strncmp(eeprom_data,"GET MM20xPCTV",13))
type = BTTV_BOARD_MODTEC_205;
- else if (0 == strncmp(eeprom_data+20,"Picolo",7))
+ else if (0 == strncmp(eeprom_data + 20, "Picolo", 6))
type = BTTV_BOARD_EURESYS_PICOLO;
else if (eeprom_data[0] == 0x84 && eeprom_data[2]== 0)
type = BTTV_BOARD_HAUPPAUGE; /* old bt848 */
@@ -912,7 +912,7 @@ liquidio_probe(struct pci_dev *pdev, const struct pci_device_id __maybe_unused *
static bool fw_type_is_auto(void)
{
return strncmp(fw_type, LIO_FW_NAME_TYPE_AUTO,
- sizeof(LIO_FW_NAME_TYPE_AUTO)) == 0;
+ sizeof(LIO_FW_NAME_TYPE_AUTO) - 1) == 0;
}
/**
@@ -207,7 +207,7 @@ static int nvec_power_bat_notifier(struct notifier_block *nb,
* This differs a little from the spec fill in more if you find
* some.
*/
- if (!strncmp(power->bat_type, "Li", 30))
+ if (!strncmp(power->bat_type, "Li", 2))
power->bat_type_enum = POWER_SUPPLY_TECHNOLOGY_LION;
else
power->bat_type_enum = POWER_SUPPLY_TECHNOLOGY_UNKNOWN;
Many times when strncmp is called with the intent of ignoring the NULL terminator, the null terminator is accidentally included in that comparison, which in practice is just an strcmp with extra steps. Subtract from the places where the intent seems to be to do a comparison without the NULL terminator. Signed-off-by: Seija Kijin <doremylover123@gmail.com> --- arch/arm/mach-omap2/sr_device.c | 8 ++++---- drivers/edac/amd64_edac.c | 2 +- drivers/edac/i10nm_base.c | 2 +- drivers/edac/igen6_edac.c | 2 +- drivers/edac/pnd2_edac.c | 2 +- drivers/edac/sb_edac.c | 2 +- drivers/edac/skx_base.c | 2 +- drivers/media/pci/bt8xx/bttv-cards.c | 2 +- drivers/net/ethernet/cavium/liquidio/lio_main.c | 2 +- drivers/staging/nvec/nvec_power.c | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-)