Skip to content

Commit 9298393

Browse files
committed
Fix warning print format strings being truncated #308
Debian 10 (Buster) has gcc 8.2 which warns about: error: ‘%s’ directive output may be truncated writing up to 19 bytes into a region of size between 10 and 59 [-Werror=format-truncation=] snprintf(path, sizeof(path), "%s/%s/state", ocp_dir, pinmux_dir);
1 parent 7032af7 commit 9298393

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

source/c_pinmux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
BBIO_err set_pin_mode(const char *key, const char *mode)
1010
{
1111
// char ocp_dir[] defined in common.h
12-
char path[60]; // "/sys/devices/platform/ocp/ocp:P#_##_pinmux/state"
12+
char path[100]; // "/sys/devices/platform/ocp/ocp:P#_##_pinmux/state"
1313
char pinmux_dir[20]; // "ocp:P#_##_pinmux"
1414
char pin[6]; //"P#_##"
1515
FILE *f = NULL;

source/common.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -636,12 +636,10 @@ BBIO_err load_device_tree(const char *name)
636636
{
637637
char line[256];
638638
FILE *file = NULL;
639-
639+
char slots[100];
640640
#ifdef BBBVERSION41
641-
char slots[41];
642641
snprintf(ctrl_dir, sizeof(ctrl_dir), "/sys/devices/platform/bone_capemgr");
643642
#else
644-
char slots[40];
645643
build_path("/sys/devices", "bone_capemgr", ctrl_dir, sizeof(ctrl_dir));
646644
#endif
647645

@@ -698,11 +696,10 @@ BBIO_err load_device_tree(const char *name)
698696
int device_tree_loaded(const char *name)
699697
{
700698
FILE *file = NULL;
699+
char slots[100];
701700
#ifdef BBBVERSION41
702-
char slots[41];
703701
snprintf(ctrl_dir, sizeof(ctrl_dir), "/sys/devices/platform/bone_capemgr");
704702
#else
705-
char slots[40];
706703
build_path("/sys/devices", "bone_capemgr", ctrl_dir, sizeof(ctrl_dir));
707704
#endif
708705
char line[256];
@@ -755,11 +752,10 @@ int device_tree_loaded(const char *name)
755752
BBIO_err unload_device_tree(const char *name)
756753
{
757754
FILE *file = NULL;
755+
char slots[100];
758756
#ifdef BBBVERSION41
759-
char slots[41];
760757
snprintf(ctrl_dir, sizeof(ctrl_dir), "/sys/devices/platform/bone_capemgr");
761758
#else
762-
char slots[40];
763759
build_path("/sys/devices", "bone_capemgr", ctrl_dir, sizeof(ctrl_dir));
764760
#endif
765761
char line[256];

0 commit comments

Comments
 (0)