diff options
author | David Kalnischkies <david@kalnischkies.de> | 2014-11-05 18:42:56 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2014-11-08 14:26:00 +0100 |
commit | ad5ffe1ffb203eb58e5e25fe6f4c0dabc53253c9 (patch) | |
tree | 8f7a58dd95f1fa7fa7061378d2cfa833960791cc /test/libapt/fileutl_test.cc | |
parent | 9dd940ed722e8235c615e79b7eb688eb427e9a23 (diff) |
Division by result of sizeof(). memset() expects a size in bytes
"did you intend to multiply instead?" is what cppcheck helpful says and
it is absolutely right. Doesn't make a whole lot of a difference though
as we are talking about 'char' in this testcase, but just to be sure.
Reported-By: cppcheck
Git-Dch: Ignore
Diffstat (limited to 'test/libapt/fileutl_test.cc')
-rw-r--r-- | test/libapt/fileutl_test.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/test/libapt/fileutl_test.cc b/test/libapt/fileutl_test.cc index 8d47c5098..57d5bbdc2 100644 --- a/test/libapt/fileutl_test.cc +++ b/test/libapt/fileutl_test.cc @@ -53,11 +53,16 @@ static void TestFileFd(mode_t const a_umask, mode_t const ExpectedFilePermission // ensure the memory is as predictably messed up #define APT_INIT_READBACK \ char readback[20]; \ - memset(readback, 'D', sizeof(readback)/sizeof(readback[0])); \ + memset(readback, 'D', sizeof(readback)*sizeof(readback[0])); \ readback[19] = '\0'; #define EXPECT_N_STR(expect, actual) \ EXPECT_EQ(0, strncmp(expect, actual, strlen(expect))); - + { + APT_INIT_READBACK + char const * const expect = "DDDDDDDDDDDDDDDDDDD"; + EXPECT_STREQ(expect,readback); + EXPECT_N_STR(expect, readback); + } { APT_INIT_READBACK char const * const expect = "This"; |