瀏覽代碼

Merge 05fbbd427b3f1044173594ffc3541fec98f614a7 into a5caacb5328605cce53faad75b7491305477834d

Christoph Böhmwalder 5 年之前
父節點
當前提交
af18346bf5
沒有帳戶連結到提交者的電子郵件
共有 2 個文件被更改,包括 4 次插入1 次删除
  1. 3
    0
      src/impl/sysfs.c
  2. 1
    1
      src/light.c

+ 3
- 0
src/impl/sysfs.c 查看文件

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

+ 1
- 1
src/light.c 查看文件

@@ -435,7 +435,7 @@ light_device_enumerator_t * light_create_enumerator(light_context_t *ctx, char c
435 435
     }
436 436
     
437 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 439
     light_device_enumerator_t *returner = new_enumerators[ctx->num_enumerators];
440 440
     
441 441
     returner->devices = NULL;