treewide: Fix code issues detected using GCC 8.2.0

Use the latest version of GCC to take advantage of improved static analysis.
These issues appeared as warnings from the compiler.

Many of these fixes are for clearly incorrect code; compiler warnings
should not be taken lightly.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
This commit is contained in:
Sultan Alsawaf 2018-08-11 18:13:12 -07:00 committed by Timi
parent 7d9b389db3
commit 6b791ecbcd
13 changed files with 40 additions and 51 deletions

View file

@ -4678,7 +4678,7 @@ again:
pce_dev->intr_cadence = 0; pce_dev->intr_cadence = 0;
atomic_set(&pce_dev->bunch_cmd_seq, 0); atomic_set(&pce_dev->bunch_cmd_seq, 0);
atomic_set(&pce_dev->last_intr_seq, 0); atomic_set(&pce_dev->last_intr_seq, 0);
pce_dev->cadence_flag = ~pce_dev->cadence_flag; pce_dev->cadence_flag = !pce_dev->cadence_flag;
} }
} }

View file

@ -2630,6 +2630,7 @@ static int qpnp_wled_probe(struct platform_device *pdev)
wled = devm_kzalloc(&pdev->dev, sizeof(*wled), GFP_KERNEL); wled = devm_kzalloc(&pdev->dev, sizeof(*wled), GFP_KERNEL);
if (!wled) if (!wled)
return -ENOMEM; return -ENOMEM;
wled->regmap = dev_get_regmap(pdev->dev.parent, NULL); wled->regmap = dev_get_regmap(pdev->dev.parent, NULL);
if (!wled->regmap) { if (!wled->regmap) {
dev_err(&pdev->dev, "Couldn't get parent's regmap\n"); dev_err(&pdev->dev, "Couldn't get parent's regmap\n");

View file

@ -171,8 +171,6 @@ static int32_t msm_vfe40_init_qos_parms(struct vfe_device *vfe_dev,
qos_regs, qos_entries); qos_regs, qos_entries);
if (rc < 0) { if (rc < 0) {
pr_err("%s: NO QOS BUS BDG info\n", __func__); pr_err("%s: NO QOS BUS BDG info\n", __func__);
kfree(qos_settings);
kfree(qos_regs);
} else { } else {
if (qos_parms->settings) { if (qos_parms->settings) {
rc = of_property_read_u32_array(of_node, rc = of_property_read_u32_array(of_node,
@ -181,21 +179,16 @@ static int32_t msm_vfe40_init_qos_parms(struct vfe_device *vfe_dev,
if (rc < 0) { if (rc < 0) {
pr_err("%s: NO QOS settings\n", pr_err("%s: NO QOS settings\n",
__func__); __func__);
kfree(qos_settings);
kfree(qos_regs);
} else { } else {
for (i = 0; i < qos_entries; i++) for (i = 0; i < qos_entries; i++)
msm_camera_io_w(qos_settings[i], msm_camera_io_w(qos_settings[i],
vfebase + qos_regs[i]); vfebase + qos_regs[i]);
}
}
}
kfree(qos_settings); kfree(qos_settings);
kfree(qos_regs); kfree(qos_regs);
} }
} else {
kfree(qos_settings);
kfree(qos_regs);
}
}
}
rc = of_property_read_u32(of_node, ds_parms->entries, rc = of_property_read_u32(of_node, ds_parms->entries,
&ds_entries); &ds_entries);
if (rc < 0 || !ds_entries) { if (rc < 0 || !ds_entries) {
@ -218,8 +211,6 @@ static int32_t msm_vfe40_init_qos_parms(struct vfe_device *vfe_dev,
ds_regs, ds_entries); ds_regs, ds_entries);
if (rc < 0) { if (rc < 0) {
pr_err("%s: NO D/S register info\n", __func__); pr_err("%s: NO D/S register info\n", __func__);
kfree(ds_settings);
kfree(ds_regs);
} else { } else {
if (ds_parms->settings) { if (ds_parms->settings) {
rc = of_property_read_u32_array(of_node, rc = of_property_read_u32_array(of_node,
@ -228,20 +219,15 @@ static int32_t msm_vfe40_init_qos_parms(struct vfe_device *vfe_dev,
if (rc < 0) { if (rc < 0) {
pr_err("%s: NO D/S settings\n", pr_err("%s: NO D/S settings\n",
__func__); __func__);
kfree(ds_settings);
kfree(ds_regs);
} else { } else {
for (i = 0; i < ds_entries; i++) for (i = 0; i < ds_entries; i++)
msm_camera_io_w(ds_settings[i], msm_camera_io_w(ds_settings[i],
vfebase + ds_regs[i]); vfebase + ds_regs[i]);
kfree(ds_regs); }
}
}
kfree(ds_settings); kfree(ds_settings);
}
} else {
kfree(ds_regs); kfree(ds_regs);
kfree(ds_settings);
}
}
} }
return 0; return 0;
} }

View file

@ -1349,7 +1349,7 @@ static int msm_probe(struct platform_device *pdev)
if (WARN_ON(rc < 0)) if (WARN_ON(rc < 0))
goto media_fail; goto media_fail;
if (WARN_ON((rc == media_entity_init(&pvdev->vdev->entity, if (WARN_ON((rc = media_entity_init(&pvdev->vdev->entity,
0, NULL, 0)) < 0)) 0, NULL, 0)) < 0))
goto entity_fail; goto entity_fail;

View file

@ -3858,17 +3858,20 @@ int msm_comm_qbuf(struct msm_vidc_inst *inst, struct vb2_buffer *vb)
* Don't queue if: * Don't queue if:
* 1) Hardware isn't ready (that's simple) * 1) Hardware isn't ready (that's simple)
*/ */
defer = defer ?: inst->state != MSM_VIDC_START_DONE; if (!defer)
defer = inst->state != MSM_VIDC_START_DONE;
/* /*
* 2) The client explicitly tells us not to because it wants this * 2) The client explicitly tells us not to because it wants this
* buffer to be batched with future frames. The batch size (on both * buffer to be batched with future frames. The batch size (on both
* capabilities) is completely determined by the client. * capabilities) is completely determined by the client.
*/ */
defer = defer ?: vbuf && vbuf->flags & V4L2_MSM_BUF_FLAG_DEFER; if (!defer)
defer = vbuf && vbuf->flags & V4L2_MSM_BUF_FLAG_DEFER;
/* 3) If we're in batch mode, we must have full batches of both types */ /* 3) If we're in batch mode, we must have full batches of both types */
defer = defer ?: batch_mode && (!output_count || !capture_count); if (!defer)
defer = batch_mode && (!output_count || !capture_count);
if (defer) { if (defer) {
dprintk(VIDC_DBG, "Deferring queue of %pK\n", vb); dprintk(VIDC_DBG, "Deferring queue of %pK\n", vb);

View file

@ -54,7 +54,7 @@ static long audio_ioctl_shared(struct file *file, unsigned int cmd,
int rc = 0; int rc = 0;
switch (cmd) { switch (cmd) {
case AUDIO_START: { case AUDIO_START:
pr_err("%s[%pK]: AUDIO_START session_id[%d]\n", __func__, pr_err("%s[%pK]: AUDIO_START session_id[%d]\n", __func__,
audio, audio->ac->session); audio, audio->ac->session);
if (audio->feedback == NON_TUNNEL_MODE) { if (audio->feedback == NON_TUNNEL_MODE) {
@ -104,10 +104,8 @@ static long audio_ioctl_shared(struct file *file, unsigned int cmd,
pr_debug("%s:AUDIO_START sessionid[%d]enable[%d]\n", __func__, pr_debug("%s:AUDIO_START sessionid[%d]enable[%d]\n", __func__,
audio->ac->session, audio->ac->session,
audio->enabled); audio->enabled);
if (audio->stopped == 1)
audio->stopped = 0; audio->stopped = 0;
break; break;
}
default: default:
pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd); pr_err("%s: Unknown ioctl cmd = %d", __func__, cmd);
rc = -EINVAL; rc = -EINVAL;

View file

@ -54,7 +54,7 @@ int __ipa_generate_rt_hw_rule_v2(enum ipa_ip_type ip,
struct ipa_hdr_entry *hdr_entry; struct ipa_hdr_entry *hdr_entry;
if (buf == NULL) { if (buf == NULL) {
memset(tmp, 0, (IPA_RT_FLT_HW_RULE_BUF_SIZE/4)); memset(tmp, 0, sizeof(tmp));
buf = (u8 *)tmp; buf = (u8 *)tmp;
} }

View file

@ -6487,11 +6487,12 @@ int cpr3_regulator_unregister(struct cpr3_controller *ctrl)
if (ctrl->irq && !cpumask_empty(&ctrl->irq_affinity_mask)) if (ctrl->irq && !cpumask_empty(&ctrl->irq_affinity_mask))
unregister_hotcpu_notifier(&ctrl->cpu_hotplug_notifier); unregister_hotcpu_notifier(&ctrl->cpu_hotplug_notifier);
if (ctrl->ctrl_type == CPR_CTRL_TYPE_CPR4) if (ctrl->ctrl_type == CPR_CTRL_TYPE_CPR4) {
rc = cpr3_ctrl_clear_cpr4_config(ctrl); rc = cpr3_ctrl_clear_cpr4_config(ctrl);
if (rc) if (rc)
cpr3_err(ctrl, "failed to clear CPR4 configuration,rc=%d\n", cpr3_err(ctrl, "failed to clear CPR4 configuration,rc=%d\n",
rc); rc);
}
cpr3_ctrl_loop_disable(ctrl); cpr3_ctrl_loop_disable(ctrl);

View file

@ -150,7 +150,6 @@ int subsys_notif_queue_notification(void *subsys_handle,
enum subsys_notif_type notif_type, enum subsys_notif_type notif_type,
void *data) void *data)
{ {
int ret = 0;
struct subsys_notif_info *subsys = struct subsys_notif_info *subsys =
(struct subsys_notif_info *) subsys_handle; (struct subsys_notif_info *) subsys_handle;
@ -160,10 +159,9 @@ int subsys_notif_queue_notification(void *subsys_handle,
if (notif_type < 0 || notif_type >= SUBSYS_NOTIF_TYPE_COUNT) if (notif_type < 0 || notif_type >= SUBSYS_NOTIF_TYPE_COUNT)
return -EINVAL; return -EINVAL;
ret = srcu_notifier_call_chain( return srcu_notifier_call_chain(
&subsys->subsys_notif_rcvr_list, notif_type, &subsys->subsys_notif_rcvr_list, notif_type,
data); data);
return ret;
} }
EXPORT_SYMBOL(subsys_notif_queue_notification); EXPORT_SYMBOL(subsys_notif_queue_notification);

View file

@ -1232,7 +1232,7 @@ static int mdss_mdp_video_wait4comp(struct mdss_mdp_ctl *ctl, void *arg)
if (rc == 0) { if (rc == 0) {
pr_warn("vsync wait timeout %d, fallback to poll mode\n", pr_warn("vsync wait timeout %d, fallback to poll mode\n",
ctl->num); ctl->num);
ctx->polling_en++; ctx->polling_en = true;
rc = mdss_mdp_video_pollwait(ctl); rc = mdss_mdp_video_pollwait(ctl);
} else { } else {
rc = 0; rc = 0;

View file

@ -397,13 +397,15 @@ static bool __wcd9xxx_switch_micbias(struct wcd9xxx_mbhc *mbhc,
pr_debug("%s: VDDIO switch enabled\n", __func__); pr_debug("%s: VDDIO switch enabled\n", __func__);
} else if (!vddio_switch && mbhc->mbhc_micbias_switched) { } else if (!vddio_switch && mbhc->mbhc_micbias_switched) {
if ((!checkpolling || mbhc->polling_active) && if ((!checkpolling || mbhc->polling_active) &&
restartpolling) restartpolling) {
wcd9xxx_pause_hs_polling(mbhc); wcd9xxx_pause_hs_polling(mbhc);
snd_soc_update_bits(codec, WCD9XXX_A_MAD_ANA_CTRL, snd_soc_update_bits(codec, WCD9XXX_A_MAD_ANA_CTRL,
0x10, 0x10); 0x10, 0x10);
snd_soc_update_bits(codec, WCD9XXX_A_LDO_H_MODE_1, snd_soc_update_bits(codec, WCD9XXX_A_LDO_H_MODE_1,
0x20, 0x20); 0x20, 0x20);
}
/* Reprogram thresholds */ /* Reprogram thresholds */
if (d->micb_mv != VDDIO_MICBIAS_MV) { if (d->micb_mv != VDDIO_MICBIAS_MV) {
cfilt_k_val = cfilt_k_val =

View file

@ -496,7 +496,7 @@ static int msm_voice_sidetone_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
int ret; int ret;
bool sidetone_enable = ucontrol->value.integer.value[0]; int sidetone_enable = ucontrol->value.integer.value[0];
uint32_t session_id = ALL_SESSION_VSID; uint32_t session_id = ALL_SESSION_VSID;
if (sidetone_enable < 0) { if (sidetone_enable < 0) {