Powered by Linux
Re: Bug-report: Smatch treats scoped_guard() as unreachable code ? — Semantic Matching Tool

Re: Bug-report: Smatch treats scoped_guard() as unreachable code ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 20/08/24 00:59, Dan Carpenter wrote:
On Tue, Aug 20, 2024 at 12:38:21AM +0530, Harshit Mogalapalli wrote:
Hey Dan,

I have noticed some warnings which mark scoped_guard() as unreachable code
on today's next.

drivers/platform/x86/ideapad-laptop.c:856 dytc_profile_set() warn: ignoring
unreachable code.


drivers/platform/x86/ideapad-laptop.c
    848  static int dytc_profile_set(struct platform_profile_handler *pprof,
    849                              enum platform_profile_option profile)
    850  {
    851          struct ideapad_dytc_priv *dytc = container_of(pprof, struct ideapad_dytc_priv, pprof);
    852          struct ideapad_private *priv = dytc->priv;
    853          unsigned long output;
    854          int err;
    855
    856          scoped_guard(mutex_intr, &dytc->mutex) {

scoped_guard is actually a for loop that iterates one time.  So the post-op
expression isn't reachable because to the return 0;  This seems like it might
be a common false positive.

Add it to smatch_data/kernel.unreachable.ignore.  Except...  Ugh, I already did
but haven't committed it yet.  I'll do that.

    857                  if (profile == PLATFORM_PROFILE_BALANCED) {
    858                          /* To get back to balanced mode we just issue a reset command */
    859                          err = eval_dytc(priv->adev->handle, DYTC_CMD_RESET, NULL);
    860                          if (err)
    861                                  return err;
    862                  } else {
    863                          int perfmode;
    864
    865                          err = convert_profile_to_dytc(profile, &perfmode);
    866                          if (err)
    867                                  return err;
    868
    869                          /* Determine if we are in CQL mode. This alters the commands we do */
    870                          err = dytc_cql_command(priv,
    871                                                 DYTC_SET_COMMAND(DYTC_FUNCTION_MMC, perfmode, 1),
    872                                                 &output);
    873                          if (err)
    874                                  return err;
    875                  }
    876
    877                  /* Success - update current profile */
    878                  dytc->current_profile = profile;
    879                  return 0;
    880          }
    881
    882          return -EINTR;
    883  }


drivers/input/touchscreen/wacom_w8001.c:383 w8001_open() warn: ignoring
unreachable code.

This one is the same.

Pushed.

Thanks for explaining and pushing the code Dan!

Harshit




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux