[compiler-rt] r229392 - tsan: fix compiler warning

David Blaikie dblaikie at gmail.com
Tue Feb 17 10:57:13 PST 2015


On Mon, Feb 16, 2015 at 5:53 AM, Dmitry Vyukov <dvyukov at google.com> wrote:

> Author: dvyukov
> Date: Mon Feb 16 07:53:00 2015
> New Revision: 229392
>
> URL: http://llvm.org/viewvc/llvm-project?rev=229392&view=rev
> Log:
> tsan: fix compiler warning
>
> mingw gcc complains:
> warning: 'err' may be used uninitialized in this function
> [-Wmaybe-uninitialized]
>        Printf("Failed to read options from '%s': error %d\n", value, err);
>

Was the warning correct? Or could we be sure that ReadFileToBuffer would
initialize 'err'?

Generally we should try not to unnecessarily initialize variables just to
satisfy warnings because it hurts sanitizers (though I suppose that
argument doesn't apply to the sanitizer libraries themselves - it still
seems like a good principle to apply)


>
>
> Modified:
>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc
>
> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc?rev=229392&r1=229391&r2=229392&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc Mon Feb 16
> 07:53:00 2015
> @@ -54,7 +54,7 @@ class FlagHandlerInclude : public FlagHa
>    bool Parse(const char *value) final {
>      char *data;
>      uptr data_mapped_size;
> -    int err;
> +    int err = 0;
>      uptr len =
>        ReadFileToBuffer(value, &data, &data_mapped_size,
>                         Max(kMaxIncludeSize, GetPageSizeCached()), &err);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150217/9d717f2b/attachment.html>


More information about the llvm-commits mailing list