diff options
author | Russell Belfer <rb@github.com> | 2013-02-16 04:02:45 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-02-16 04:02:45 +0400 |
commit | 56543a609aa7adb14b308046445ddd48f44322b7 (patch) | |
tree | da381d33ee3e01de4f957bf748dacb749a55be3a /tests-clar/clar_libgit2.c | |
parent | 71d62d3905723c0263ca00a1d68825e2c35fb987 (diff) |
Clear up warnings from cppcheck
The cppcheck static analyzer generates warnings for a bunch of
places in the libgit2 code base. All the ones fixed in this
commit are actually false positives, but I've reorganized the
code to hopefully make it easier for static analysis tools to
correctly understand the structure. I wouldn't do this if I
felt like it was making the code harder to read or worse for
humans, but in this case, these fixes don't seem too bad and will
hopefully make it easier for better analysis tools to get at any
real issues.
Diffstat (limited to 'tests-clar/clar_libgit2.c')
-rw-r--r-- | tests-clar/clar_libgit2.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/tests-clar/clar_libgit2.c b/tests-clar/clar_libgit2.c index 63efd5954..698aa90f0 100644 --- a/tests-clar/clar_libgit2.c +++ b/tests-clar/clar_libgit2.c @@ -86,14 +86,18 @@ int cl_setenv(const char *name, const char *value) git__utf8_to_16(name_utf16, GIT_WIN_PATH, name); - if (value != NULL) + if (value) { git__utf8_to_16(value_utf16, GIT_WIN_PATH, value); + cl_assert(SetEnvironmentVariableW(name_utf16, value_utf16)); + } else { + /* Windows XP returns 0 (failed) when passing NULL for lpValue when + * lpName does not exist in the environment block. This behavior + * seems to have changed in later versions. Don't check return value + * of SetEnvironmentVariable when passing NULL for lpValue. + */ + SetEnvironmentVariableW(name_utf16, NULL); + } - /* Windows XP returns 0 (failed) when passing NULL for lpValue when lpName - * does not exist in the environment block. This behavior seems to have changed - * in later versions. Don't fail when SetEnvironmentVariable fails, if we passed - * NULL for lpValue. */ - cl_assert(SetEnvironmentVariableW(name_utf16, value ? value_utf16 : NULL) || !value); return 0; } |