[lxc-devel] [lxc/lxc] ba464e: cmd: Do not reassign variable before it is used

GitHub noreply at github.com
Mon Aug 20 23:37:32 UTC 2018


  Branch: refs/heads/master
  Home:   https://github.com/lxc/lxc
  Commit: ba464e9b6672cf1b3e96a0c0efb3ee55ad4156ee
      https://github.com/lxc/lxc/commit/ba464e9b6672cf1b3e96a0c0efb3ee55ad4156ee
  Author: Tobin C. Harding <me at tobin.cc>
  Date:   2018-08-21 (Tue, 21 Aug 2018)

  Changed paths:
    M src/lxc/cmd/lxc_user_nic.c

  Log Message:
  -----------
  cmd: Do not reassign variable before it is used

cppcheck emits warning

  Variable 'ofd' is reassigned a value before the old one has been used.

We do not need to initialise a variable if it is assigned to on first use.

Signed-off-by: Tobin C. Harding <me at tobin.cc>


  Commit: aac44dc4ff44a70689f657829ccda2b3aeeb595f
      https://github.com/lxc/lxc/commit/aac44dc4ff44a70689f657829ccda2b3aeeb595f
  Author: Tobin C. Harding <me at tobin.cc>
  Date:   2018-08-21 (Tue, 21 Aug 2018)

  Changed paths:
    M src/lxc/cmd/lxc_user_nic.c

  Log Message:
  -----------
  cmd: Reduce scope of 'count' variable

Variable is used in one plaice only within a nested statement block.
The code is cleaner if the variable is declared near where it is used.
Found using cppcheck.

Reduce the scope of 'count' variable.

Signed-off-by: Tobin C. Harding <me at tobin.cc>


  Commit: 06d390dfb9d67b69ab107341ed3589b6f744e5bf
      https://github.com/lxc/lxc/commit/06d390dfb9d67b69ab107341ed3589b6f744e5bf
  Author: Christian Brauner <christian at brauner.io>
  Date:   2018-08-21 (Tue, 21 Aug 2018)

  Changed paths:
    M src/lxc/cmd/lxc_user_nic.c

  Log Message:
  -----------
  Merge pull request #2552 from tcharding/cpp-check

cmd: Lint with cppcheck


Compare: https://github.com/lxc/lxc/compare/86cea5d14315...06d390dfb9d6
      **NOTE:** This service has been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

      Functionality will be removed from GitHub.com on January 31st, 2019.


More information about the lxc-devel mailing list