Browse Source

Merge 05fbbd427b3f1044173594ffc3541fec98f614a7 into a5caacb5328605cce53faad75b7491305477834d

Christoph Böhmwalder 6 years ago
parent
commit
af18346bf5
No account linked to committer's email
2 changed files with 4 additions and 1 deletions
  1. 3
    0
      src/impl/sysfs.c
  2. 1
    1
      src/light.c

+ 3
- 0
src/impl/sysfs.c View File

5
 
5
 
6
 #include <stdio.h> //snprintf
6
 #include <stdio.h> //snprintf
7
 #include <stdlib.h> // malloc, free
7
 #include <stdlib.h> // malloc, free
8
+#include <string.h> // memset
8
 #include <dirent.h> // opendir, readdir
9
 #include <dirent.h> // opendir, readdir
9
 
10
 
10
 static bool _impl_sysfs_init_leds(light_device_enumerator_t *enumerator)
11
 static bool _impl_sysfs_init_leds(light_device_enumerator_t *enumerator)
11
 {
12
 {
12
     // Create a new backlight device
13
     // Create a new backlight device
13
     light_device_t *leds_device = malloc(sizeof(light_device_t));
14
     light_device_t *leds_device = malloc(sizeof(light_device_t));
15
+    memset(leds_device, 0, sizeof(light_device_t));
14
     snprintf(leds_device->name, sizeof(leds_device->name), "%s", "leds");
16
     snprintf(leds_device->name, sizeof(leds_device->name), "%s", "leds");
15
     
17
     
16
     // Add it to the enumerator 
18
     // Add it to the enumerator 
63
 {
65
 {
64
     // Create a new backlight device
66
     // Create a new backlight device
65
     light_device_t *backlight_device = malloc(sizeof(light_device_t));
67
     light_device_t *backlight_device = malloc(sizeof(light_device_t));
68
+    memset(backlight_device, 0, sizeof(light_device_t));
66
     snprintf(backlight_device->name, sizeof(backlight_device->name), "%s", "backlight");
69
     snprintf(backlight_device->name, sizeof(backlight_device->name), "%s", "backlight");
67
     
70
     
68
     // Add it to the enumerator 
71
     // Add it to the enumerator 

+ 1
- 1
src/light.c View File

435
     }
435
     }
436
     
436
     
437
     // Allocate the new enumerator
437
     // Allocate the new enumerator
438
-    new_enumerators[ctx->num_enumerators] = malloc(sizeof(light_device_enumerator_t*));
438
+    new_enumerators[ctx->num_enumerators] = malloc(sizeof(light_device_enumerator_t));
439
     light_device_enumerator_t *returner = new_enumerators[ctx->num_enumerators];
439
     light_device_enumerator_t *returner = new_enumerators[ctx->num_enumerators];
440
     
440
     
441
     returner->devices = NULL;
441
     returner->devices = NULL;