xrandr: Fix variable declaration warnings
authorAaron Plattner <aplattner@nvidia.com>
Sat, 25 Aug 2012 04:43:13 +0000 (21:43 -0700)
committerAaron Plattner <aplattner@nvidia.com>
Tue, 12 Feb 2013 18:09:51 +0000 (10:09 -0800)
commitdac72dbbc7501483eccec71bbf0db05a56756109
tree4e2a36018dd0d167e0ee0c388f5613fc94b7b46d
parent138b6252c0cae6599b6c8a25ffa22ffe70f227c2
xrandr: Fix variable declaration warnings

There are piles of places in the code where a variable shadows either another
variable or a global function:

  xrandr.c:545:35: warning: declaration of ‘index’ shadows a global declaration [-Wshadow]
  xrandr.c:574:9: warning: declaration of ‘index’ shadows a global declaration [-Wshadow]
  xrandr.c:967:19: warning: declaration of ‘gamma’ shadows a global declaration [-Wshadow]
  xrandr.c:1329:16: warning: declaration of ‘gamma’ shadows a global declaration [-Wshadow]
  xrandr.c:2055:28: warning: declaration of ‘outputs’ shadows a global declaration [-Wshadow]
  xrandr.c:2068:29: warning: declaration of ‘outputs’ shadows a global declaration [-Wshadow]
  xrandr.c:2928:16: warning: declaration of ‘output’ shadows a previous local [-Wshadow]
  xrandr.c:2995:15: warning: declaration of ‘output’ shadows a previous local [-Wshadow]
  xrandr.c:3016:15: warning: declaration of ‘j’ shadows a previous local [-Wshadow]
  xrandr.c:3018:19: warning: declaration of ‘rotations’ shadows a previous local [-Wshadow]
  xrandr.c:3116:15: warning: declaration of ‘crtc’ shadows a previous local [-Wshadow]
  xrandr.c:3170:8: warning: declaration of ‘k’ shadows a previous local [-Wshadow]
  xrandr.c:3243:20: warning: declaration of ‘mode’ shadows a previous local [-Wshadow]

'index' and 'gamma' are C library functions:

  index (3)            - locate character in string
  gamma (3)            - (logarithm of the) gamma function

The rest of these are either variables or function parameters.

When possible, move the declaration of a variable into the block where it is
used, including in cases where the same variable is used in multiple blocks but
the later block doesn't depend on the value from the earlier block.

In a few cases, rename the variable in the outer scope to be more specific (e.g.
output -> config_output) so the more generic variable in the inner scope (e.g.
the 'output' variable used to iterate over all outputs) doesn't have to change.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Reviewed-by: Andy Ritger <aritger@nvidia.com>
xrandr.c