drm: use mem_is_zero() instead of !memchr_inv(s, 0, n)
Use the mem_is_zero() helper where possible. Conversion done using cocci: | @@ | expression PTR; | expression SIZE; | @@ | | <... | ( | - memchr_inv(PTR, 0, SIZE) == NULL | + mem_is_zero(PTR, SIZE) | | | - !memchr_inv(PTR, 0, SIZE) | + mem_is_zero(PTR, SIZE) | | | - memchr_inv(PTR, 0, SIZE) | + !mem_is_zero(PTR, SIZE) | ) | ...> Reviewed-by: Kees Cook <kees@kernel.org> Link: https://patchwork.freedesktop.org/patch/msgid/20240814100035.3100852-2-jani.nikula@intel.com Signed-off-by: Jani Nikula <jani.nikula@intel.com>
This commit is contained in:
parent
3942bb4972
commit
f765063580
@ -1817,7 +1817,7 @@ static int edid_block_tag(const void *_block)
|
||||
|
||||
static bool edid_block_is_zero(const void *edid)
|
||||
{
|
||||
return !memchr_inv(edid, 0, EDID_LENGTH);
|
||||
return mem_is_zero(edid, EDID_LENGTH);
|
||||
}
|
||||
|
||||
static bool drm_edid_eq(const struct drm_edid *drm_edid,
|
||||
|
@ -5077,7 +5077,7 @@ intel_dp_check_mst_status(struct intel_dp *intel_dp)
|
||||
ack[3] |= DP_TUNNELING_IRQ;
|
||||
}
|
||||
|
||||
if (!memchr_inv(ack, 0, sizeof(ack)))
|
||||
if (mem_is_zero(ack, sizeof(ack)))
|
||||
break;
|
||||
|
||||
if (!intel_dp_ack_sink_irq_esi(intel_dp, ack))
|
||||
|
@ -1117,7 +1117,7 @@ const struct drm_edid *intel_opregion_get_edid(struct intel_connector *intel_con
|
||||
|
||||
/* Validity corresponds to number of 128-byte blocks */
|
||||
len = (opregion->asle_ext->phed & ASLE_PHED_EDID_VALID_MASK) * 128;
|
||||
if (!len || !memchr_inv(edid, 0, len))
|
||||
if (!len || mem_is_zero(edid, len))
|
||||
return NULL;
|
||||
|
||||
drm_edid = drm_edid_alloc(edid, len);
|
||||
|
@ -506,7 +506,7 @@ static int igt_dmabuf_export_vmap(void *arg)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (memchr_inv(ptr, 0, dmabuf->size)) {
|
||||
if (!mem_is_zero(ptr, dmabuf->size)) {
|
||||
pr_err("Exported object not initialised to zero!\n");
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
|
@ -668,7 +668,7 @@ pvr_ioctl_union_padding_check(void *instance, size_t union_offset,
|
||||
void *padding_start = ((u8 *)instance) + union_offset + member_size;
|
||||
size_t padding_size = union_size - member_size;
|
||||
|
||||
return !memchr_inv(padding_start, 0, padding_size);
|
||||
return mem_is_zero(padding_start, padding_size);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,7 +69,7 @@ bool udl_probe_edid(struct udl_device *udl)
|
||||
* The adapter sends all-zeros if no monitor has been
|
||||
* connected. We consider anything else a connection.
|
||||
*/
|
||||
return !!memchr_inv(hdr, 0, sizeof(hdr));
|
||||
return !mem_is_zero(hdr, sizeof(hdr));
|
||||
}
|
||||
|
||||
const struct drm_edid *udl_edid_read(struct drm_connector *connector)
|
||||
|
Loading…
Reference in New Issue
Block a user