Selaa lähdekoodia

Remove a bool in pdb_dpm_evaluate_typec_current

The cfg_set variable was not necessary after all, since testing if
cfg == NULL works just as well as testing if !cfg_set.  Actually a bit
better, since it prevents a null dereference we did by mistake before.
I should find out if the null derefernce hurts anything, because if it
does I should make a patch to the 1.1.x series to fix it.
Clara Hobbs 7 vuotta sitten
vanhempi
commit
b28d119560
1 muutettua tiedostoa jossa 1 lisäystä ja 3 poistoa
  1. 1
    3
      src/device_policy_manager.c

+ 1
- 3
src/device_policy_manager.c Näytä tiedosto

@@ -187,14 +187,12 @@ bool pdb_dpm_giveback_enabled(void)
187 187
 
188 188
 bool pdb_dpm_evaluate_typec_current(void)
189 189
 {
190
-    static bool cfg_set = false;
191 190
     static struct pdb_config *cfg = NULL;
192 191
 
193 192
     /* Get the configuration the first time this function runs, and again any
194 193
      * time the status is found to not be valid. */
195
-    if (!cfg_set || cfg->status != PDB_CONFIG_STATUS_VALID) {
194
+    if (cfg == NULL || cfg->status != PDB_CONFIG_STATUS_VALID) {
196 195
         cfg = pdb_config_flash_read();
197
-        cfg_set = true;
198 196
     }
199 197
 
200 198
     /* We don't control the voltage anymore; it will always be 5 V. */

Loading…
Peruuta
Tallenna