src/power/SDL_power.c
changeset 12331 43d46306c3ba
parent 11811 5d94cb6b24d3
child 12503 806492103856
     1.1 --- a/src/power/SDL_power.c	Mon Oct 15 00:46:43 2018 -0400
     1.2 +++ b/src/power/SDL_power.c	Mon Oct 15 11:01:00 2018 +0300
     1.3 @@ -42,11 +42,8 @@
     1.4      return SDL_TRUE;
     1.5  }
     1.6  #endif
     1.7 -#endif
     1.8 -
     1.9  
    1.10  static SDL_GetPowerInfo_Impl implementations[] = {
    1.11 -#ifndef SDL_POWER_DISABLED
    1.12  #ifdef SDL_POWER_LINUX          /* in order of preference. More than could work. */
    1.13      SDL_GetPowerInfo_Linux_org_freedesktop_upower,
    1.14      SDL_GetPowerInfo_Linux_sys_class_power_supply,
    1.15 @@ -81,31 +78,34 @@
    1.16  #ifdef SDL_POWER_HARDWIRED
    1.17      SDL_GetPowerInfo_Hardwired,
    1.18  #endif
    1.19 +};
    1.20  #endif
    1.21 -};
    1.22  
    1.23  SDL_PowerState
    1.24  SDL_GetPowerInfo(int *seconds, int *percent)
    1.25  {
    1.26 +#ifndef SDL_POWER_DISABLED
    1.27      const int total = sizeof(implementations) / sizeof(implementations[0]);
    1.28 -    int _seconds, _percent;
    1.29      SDL_PowerState retval = SDL_POWERSTATE_UNKNOWN;
    1.30      int i;
    1.31 +#endif
    1.32  
    1.33 +    int _seconds, _percent;
    1.34      /* Make these never NULL for platform-specific implementations. */
    1.35      if (seconds == NULL) {
    1.36          seconds = &_seconds;
    1.37      }
    1.38 -
    1.39      if (percent == NULL) {
    1.40          percent = &_percent;
    1.41      }
    1.42  
    1.43 +#ifndef SDL_POWER_DISABLED
    1.44      for (i = 0; i < total; i++) {
    1.45          if (implementations[i](&retval, seconds, percent)) {
    1.46              return retval;
    1.47          }
    1.48      }
    1.49 +#endif
    1.50  
    1.51      /* nothing was definitive. */
    1.52      *seconds = -1;