Skip to content

Commit

Permalink
Fix warning print format strings being truncated #308
Browse files Browse the repository at this point in the history
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);
  • Loading branch information
pdp7 committed Dec 6, 2019
1 parent 7032af7 commit 9298393
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion source/c_pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
BBIO_err set_pin_mode(const char *key, const char *mode)
{
// char ocp_dir[] defined in common.h
char path[60]; // "/sys/devices/platform/ocp/ocp:P#_##_pinmux/state"
char path[100]; // "/sys/devices/platform/ocp/ocp:P#_##_pinmux/state"
char pinmux_dir[20]; // "ocp:P#_##_pinmux"
char pin[6]; //"P#_##"
FILE *f = NULL;
Expand Down
10 changes: 3 additions & 7 deletions source/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,12 +636,10 @@ BBIO_err load_device_tree(const char *name)
{
char line[256];
FILE *file = NULL;

char slots[100];
#ifdef BBBVERSION41
char slots[41];
snprintf(ctrl_dir, sizeof(ctrl_dir), "/sys/devices/platform/bone_capemgr");
#else
char slots[40];
build_path("/sys/devices", "bone_capemgr", ctrl_dir, sizeof(ctrl_dir));
#endif

Expand Down Expand Up @@ -698,11 +696,10 @@ BBIO_err load_device_tree(const char *name)
int device_tree_loaded(const char *name)
{
FILE *file = NULL;
char slots[100];
#ifdef BBBVERSION41
char slots[41];
snprintf(ctrl_dir, sizeof(ctrl_dir), "/sys/devices/platform/bone_capemgr");
#else
char slots[40];
build_path("/sys/devices", "bone_capemgr", ctrl_dir, sizeof(ctrl_dir));
#endif
char line[256];
Expand Down Expand Up @@ -755,11 +752,10 @@ int device_tree_loaded(const char *name)
BBIO_err unload_device_tree(const char *name)
{
FILE *file = NULL;
char slots[100];
#ifdef BBBVERSION41
char slots[41];
snprintf(ctrl_dir, sizeof(ctrl_dir), "/sys/devices/platform/bone_capemgr");
#else
char slots[40];
build_path("/sys/devices", "bone_capemgr", ctrl_dir, sizeof(ctrl_dir));
#endif
char line[256];
Expand Down

0 comments on commit 9298393

Please sign in to comment.