From 1f3bfe7b5d437ae3ecd202e0e224a62dbc98b133 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Fri, 20 Jul 2018 14:27:57 +0530 Subject: glusterd: fix gcc7 warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [sh]$ gcc --version gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5) Warnings were of the type below: xlators/mgmt/glusterd/src/glusterd-store.c:3285:33: warning: ‘/options’ directive output may be truncated writing 8 bytes into a region of size between 1 and 4096 [-Wformat-truncation=] snprintf (path, len, "%s/options", conf->workdir); ^~~~~~~~ xlators/mgmt/glusterd/src/glusterd-store.c:1280:39: warning: ‘/snaps/’ directive output may be truncated writing 7 bytes into a region of size between 1 and 4096 [-Wformat-truncation=] snprintf (snap_fpath, len, "%s/snaps/%s/%s", priv->workdir, ^~~~~~~ * Also changed some places where there was issues with key size * Made sure all the 'char buf[SOMESIZE] = {0,};' are changed to 'char buf[SOMESIZE] = "";` - In the files I changed * Also edited coding standard to reflect that. updates: bz#1193929 Change-Id: I04c652624ac63199cea2077e46b3a5def37c3689 Signed-off-by: Amar Tumballi --- doc/developer-guide/coding-standard.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'doc/developer-guide') diff --git a/doc/developer-guide/coding-standard.md b/doc/developer-guide/coding-standard.md index eb9cd9ddc39..9bc15a5cc15 100644 --- a/doc/developer-guide/coding-standard.md +++ b/doc/developer-guide/coding-standard.md @@ -156,6 +156,28 @@ instead. gf_boolean_t port_inuse[65536]; /* 256KB, this actually happened */ ``` +NOTE: Ideal is to limit the stack array to less than 256 bytes. + + +Character array initializing +---------------------------- + +It is recommended to keep the character array initializing to empty string. + +*Good:* +``` +char msg[1024] = ""; +``` + +Not so much recommended, even though it means the same. + +``` +char msg[1024] = {0,}; +``` + +We recommend above to structure initialization. + + Validate all arguments to a function ------------------------------------ -- cgit