mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-06 20:58:33 +01:00
Suppress Clang warning on adding an integer to a string
Suppress Clang warning on adding an integer to a string, like: tst-iconv-sticky-input-error.c:125:42: error: adding 'int' to a string does not append to the string [-Werror,-Wstring-plus-int] 125 | expected_output = "ABXY" + skip; | ~~~~~~~^~~~~~ tst-iconv-sticky-input-error.c:125:42: note: use array indexing to silence this warning 125 | expected_output = "ABXY" + skip; | ^ | & [ ] Co-Authored-By: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
This commit is contained in:
parent
77c1128bd3
commit
27a4b6421f
4 changed files with 16 additions and 0 deletions
|
@ -26,6 +26,7 @@
|
||||||
#include <support/support.h>
|
#include <support/support.h>
|
||||||
#include <support/xdirent.h>
|
#include <support/xdirent.h>
|
||||||
#include <support/readdir.h>
|
#include <support/readdir.h>
|
||||||
|
#include <libc-diag.h>
|
||||||
|
|
||||||
/* If positive, at this length an EMSGSIZE error is injected. */
|
/* If positive, at this length an EMSGSIZE error is injected. */
|
||||||
static _Atomic int inject_error_at_length;
|
static _Atomic int inject_error_at_length;
|
||||||
|
@ -59,7 +60,10 @@ add_directory_entry (struct support_fuse_dirstream *d, uint64_t offset)
|
||||||
if (offset <= 1)
|
if (offset <= 1)
|
||||||
{
|
{
|
||||||
type = DT_DIR;
|
type = DT_DIR;
|
||||||
|
DIAG_PUSH_NEEDS_COMMENT_CLANG;
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wstring-plus-int");
|
||||||
name = ".." + !offset; /* "." or "..". */
|
name = ".." + !offset; /* "." or "..". */
|
||||||
|
DIAG_POP_NEEDS_COMMENT_CLANG;
|
||||||
ino = 1;
|
ino = 1;
|
||||||
}
|
}
|
||||||
else if (length == 1000)
|
else if (length == 1000)
|
||||||
|
|
|
@ -24,17 +24,21 @@
|
||||||
#include <support/readdir.h>
|
#include <support/readdir.h>
|
||||||
#include <support/support.h>
|
#include <support/support.h>
|
||||||
#include <support/xdirent.h>
|
#include <support/xdirent.h>
|
||||||
|
#include <libc-diag.h>
|
||||||
|
|
||||||
/* Return the file name at the indicated directory offset. */
|
/* Return the file name at the indicated directory offset. */
|
||||||
static char *
|
static char *
|
||||||
name_at_offset (unsigned int offset)
|
name_at_offset (unsigned int offset)
|
||||||
{
|
{
|
||||||
|
DIAG_PUSH_NEEDS_COMMENT_CLANG;
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wstring-plus-int");
|
||||||
if (offset <= 1)
|
if (offset <= 1)
|
||||||
return xstrdup (".." + !offset); /* "." or "..". */
|
return xstrdup (".." + !offset); /* "." or "..". */
|
||||||
else
|
else
|
||||||
/* Pad the name with a lot of zeros, so that the dirent buffer gets
|
/* Pad the name with a lot of zeros, so that the dirent buffer gets
|
||||||
filled more quickly. */
|
filled more quickly. */
|
||||||
return xasprintf ("file%0240u", offset);
|
return xasprintf ("file%0240u", offset);
|
||||||
|
DIAG_POP_NEEDS_COMMENT_CLANG;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This many directory entries, including "." and "..". */
|
/* This many directory entries, including "." and "..". */
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <support/support.h>
|
#include <support/support.h>
|
||||||
#include <support/test-driver.h>
|
#include <support/test-driver.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <libc-diag.h>
|
||||||
|
|
||||||
/* FROM is the input character set, TO the output character set. If
|
/* FROM is the input character set, TO the output character set. If
|
||||||
IGNORE is true, the iconv descriptor is set up in the same way as
|
IGNORE is true, the iconv descriptor is set up in the same way as
|
||||||
|
@ -121,12 +122,15 @@ do_test (void)
|
||||||
for (int skip = 0; skip < 3; ++skip)
|
for (int skip = 0; skip < 3; ++skip)
|
||||||
{
|
{
|
||||||
const char *expected_output;
|
const char *expected_output;
|
||||||
|
DIAG_PUSH_NEEDS_COMMENT_CLANG;
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wstring-plus-int");
|
||||||
if (do_ignore || strstr (charsets[to_idx], "//IGNORE") != NULL)
|
if (do_ignore || strstr (charsets[to_idx], "//IGNORE") != NULL)
|
||||||
expected_output = "ABXY" + skip;
|
expected_output = "ABXY" + skip;
|
||||||
else
|
else
|
||||||
expected_output = "AB" + skip;
|
expected_output = "AB" + skip;
|
||||||
one_direction (charsets[from_idx], charsets[to_idx], do_ignore,
|
one_direction (charsets[from_idx], charsets[to_idx], do_ignore,
|
||||||
"AB\xffXY" + skip, expected_output, limit);
|
"AB\xffXY" + skip, expected_output, limit);
|
||||||
|
DIAG_POP_NEEDS_COMMENT_CLANG;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <libc-diag.h>
|
||||||
|
|
||||||
#define str "civic"
|
#define str "civic"
|
||||||
|
|
||||||
|
@ -45,11 +46,14 @@ do_test (void)
|
||||||
{
|
{
|
||||||
int len = m[i].rm_eo - m[i].rm_so;
|
int len = m[i].rm_eo - m[i].rm_so;
|
||||||
|
|
||||||
|
DIAG_PUSH_NEEDS_COMMENT_CLANG;
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wstring-plus-int");
|
||||||
printf ("m[%d] = \"%.*s\"\n", i, len, str + m[i].rm_so);
|
printf ("m[%d] = \"%.*s\"\n", i, len, str + m[i].rm_so);
|
||||||
|
|
||||||
if (strlen (expected[i]) != len
|
if (strlen (expected[i]) != len
|
||||||
|| memcmp (expected[i], str + m[i].rm_so, len) != 0)
|
|| memcmp (expected[i], str + m[i].rm_so, len) != 0)
|
||||||
result = 1;
|
result = 1;
|
||||||
|
DIAG_POP_NEEDS_COMMENT_CLANG;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Add table
Reference in a new issue