From: Masatake YAMATO <yamato@redhat.com>
To: linux-sparse@vger.kernel.org
Cc: yamato@redhat.com
Subject: [PATCH 3/3] Add description for -Winit-cstring option
Date: Sun, 7 Apr 2013 01:58:57 +0900 [thread overview]
Message-ID: <1365267537-3787-3-git-send-email-yamato@redhat.com> (raw)
In-Reply-To: <1365267537-3787-1-git-send-email-yamato@redhat.com>
This patch added description for -Winit-cstring option
to sparse.1.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
sparse.1 | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/sparse.1 b/sparse.1
index ae85b54..cd6be26 100644
--- a/sparse.1
+++ b/sparse.1
@@ -189,6 +189,24 @@ Sparse issues these warnings by default. To turn them off, use
\fB\-Wno\-enum\-mismatch\fR.
.
.TP
+.B \-Winit\-cstring
+Warn about initialization of a char array with a too long constant C string.
+
+If the size of the char array and the length of the string is the same,
+there is no space for the last nul char of the string in the array:
+
+.nf
+char s[3] = "abc";
+.fi
+
+If the array is used as a byte array, not as C string, this
+warning is just noise. However, if the array is passed to functions
+dealing with C string like printf(%s) and strcmp, it may cause a
+trouble.
+
+Sparse does not issue these warnings by default.
+.
+.TP
.B \-Wnon\-pointer\-null
Warn about the use of 0 as a NULL pointer.
--
1.7.11.7
next prev parent reply other threads:[~2013-04-06 17:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-06 16:58 [PATCH 1/3] Warn about initialization of a char array with a too long constant C string Masatake YAMATO
2013-04-06 16:58 ` [PATCH 2/3] Test case for -Winit-cstring option Masatake YAMATO
2013-04-06 16:58 ` Masatake YAMATO [this message]
2013-04-22 16:42 ` [PATCH 1/3] Warn about initialization of a char array with a too long constant C string Christopher Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1365267537-3787-3-git-send-email-yamato@redhat.com \
--to=yamato@redhat.com \
--cc=linux-sparse@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).