Skip to content

Commit 3252ee4

Browse files
Leo-YanSuzuki K Poulose
authored andcommitted
coresight: stm: Remove redundant NULL checks
container_of() cannot return NULL, so the checks for NULL pointers are unnecessary and can be safely removed. As a result, this commit silences the following smatch warnings: coresight-stm.c:345 stm_generic_link() warn: can 'drvdata' even be NULL? coresight-stm.c:356 stm_generic_unlink() warn: can 'drvdata' even be NULL? coresight-stm.c:387 stm_generic_set_options() warn: can 'drvdata' even be NULL? coresight-stm.c:422 stm_generic_packet() warn: can 'drvdata' even be NULL? Signed-off-by: Leo Yan <leo.yan@arm.com> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20250611-arm_cs_fix_smatch_warning_v1-v1-1-02a66c69b604@arm.com
1 parent 9ba5502 commit 3252ee4

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/hwtracing/coresight/coresight-stm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ static int stm_generic_link(struct stm_data *stm_data,
342342
{
343343
struct stm_drvdata *drvdata = container_of(stm_data,
344344
struct stm_drvdata, stm);
345-
if (!drvdata || !drvdata->csdev)
345+
if (!drvdata->csdev)
346346
return -EINVAL;
347347

348348
return coresight_enable_sysfs(drvdata->csdev);
@@ -353,7 +353,7 @@ static void stm_generic_unlink(struct stm_data *stm_data,
353353
{
354354
struct stm_drvdata *drvdata = container_of(stm_data,
355355
struct stm_drvdata, stm);
356-
if (!drvdata || !drvdata->csdev)
356+
if (!drvdata->csdev)
357357
return;
358358

359359
coresight_disable_sysfs(drvdata->csdev);
@@ -384,7 +384,7 @@ static long stm_generic_set_options(struct stm_data *stm_data,
384384
{
385385
struct stm_drvdata *drvdata = container_of(stm_data,
386386
struct stm_drvdata, stm);
387-
if (!(drvdata && coresight_get_mode(drvdata->csdev)))
387+
if (!coresight_get_mode(drvdata->csdev))
388388
return -EINVAL;
389389

390390
if (channel >= drvdata->numsp)
@@ -419,7 +419,7 @@ static ssize_t notrace stm_generic_packet(struct stm_data *stm_data,
419419
struct stm_drvdata, stm);
420420
unsigned int stm_flags;
421421

422-
if (!(drvdata && coresight_get_mode(drvdata->csdev)))
422+
if (!coresight_get_mode(drvdata->csdev))
423423
return -EACCES;
424424

425425
if (channel >= drvdata->numsp)

0 commit comments

Comments
 (0)