Skip to content

Commit 149129c

Browse files
author
Matthew West
committed
Initialize ocp_dir before use
1 parent b0c90d5 commit 149129c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

source/c_pwm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,12 @@ BBIO_err pwm_setup(const char *key, float duty, float freq, int polarity)
404404
//creates the fragment in order to build the pwm_test_filename, such as "pwm_test_P9_13"
405405
snprintf(pwm_fragment, sizeof(pwm_fragment), "pwm_test_%s", key);
406406

407+
// Initialize the ocp_dir
408+
err = build_path("/sys/devices", "ocp", ocp_dir, sizeof(ocp_dir));
409+
if (err != BBIO_OK) {
410+
return err;
411+
}
412+
407413
//finds and builds the pwm_path, as it can be variable...
408414
err = build_path(ocp_dir, pwm_fragment, pwm_path, sizeof(pwm_path));
409415
if (err != BBIO_OK) {

0 commit comments

Comments
 (0)