Skip to content

Remove warnings#5078

Merged
ethomson merged 41 commits intomasterfrom
ethomson/warnings
Jun 25, 2019
Merged

Remove warnings#5078
ethomson merged 41 commits intomasterfrom
ethomson/warnings

Conversation

@ethomson
Copy link
Copy Markdown
Member

We've still got some warnings when compiling on Windows amd64. I want them eliminated.

@ethomson ethomson force-pushed the ethomson/warnings branch 2 times, most recently from 73892de to 57f1918 Compare May 20, 2019 16:55
Copy link
Copy Markdown
Member

@pks-t pks-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh, thanks for working on this! I think I've never before seen a warning-free build on MSVC. Didn't know that this was possible

size_t buflen = u->field_data[UF_HOST].off + u->field_data[UF_HOST].len;

if (buflen > UINT16_MAX)
return 1;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunate that we're diverging from upstream http-parser. I think we should apply this for now, but try to upstream those changes and then re-sync our copy.

Comment thread src/iterator.c Outdated
return -1;
}

entry = git_pool_malloc(&frame->entry_pool, (uint32_t)entry_size);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd argue that git_pool_malloc should be using size_t, but as it's of theoretical value only I'm happy with this, too.

Comment thread src/merge.c Outdated
git_error_set(GIT_ERROR_MERGE, "merged file contents too large for index");
error = -1;
goto done;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this means we're not able to solve merge conflicts on 4GB files? Unlikely, but it could very well be that somebody has written a merge conflict driver for binary files that is able to resolve such conflicts. On the other hand, this is not a new restriction and at least we're being explicit now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I'd forgotten how the index handles files > 4GB. In fact, we should be truncating the file size to a uint32_t in the cache. I updated this to remove this (incorrect) check.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure, I can't remember how this looked before. Is this already the updated version? Cannot see any "outdated" marker.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right! Sorry, I must not have pushed up a fixed. (It's now pushed up.)

Comment thread src/trailer.c

/*
* Return the position of the start of the last line. If len is 0, return -1.
* Return the position of the start of the last line. If len is 0, return 0.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot discern text with zero length and text with a single line only, now, can we? Both would return 0. I think it'd be cleaner to just use an out parameter here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed; fixed.

@ethomson ethomson force-pushed the ethomson/warnings branch 2 times, most recently from fc2cbb7 to 664dabb Compare May 21, 2019 14:28
@ethomson
Copy link
Copy Markdown
Member Author

Oooh, thanks for working on this! I think I've never before seen a warning-free build on MSVC. Didn't know that this was possible

We're warning free on MSVC x86 builds today; this just fixes up amd64. One of the tricky bits here is that in the win32 ecosystem is that int and long are always 32 bit (LLP64). So if one sloppily assumes that they're in an LP64 world where long is 64 bits, then that's obviously very wrong.

@azuredevopsuser
Copy link
Copy Markdown

/rebuild

@libgit2-azure-pipelines
Copy link
Copy Markdown

Sorry @azuredevopsuser, you're not allowed to do that.

@ethomson ethomson force-pushed the ethomson/warnings branch 2 times, most recently from 1e393c0 to 0801b76 Compare May 25, 2019 18:35
@pks-t
Copy link
Copy Markdown
Member

pks-t commented Jun 14, 2019

Mhh. It's unfortunate that VSTS deletes the latest build on still existing pull requests :/ Makes it impossible to see what's caused the error without a rebuild

@pks-t
Copy link
Copy Markdown
Member

pks-t commented Jun 14, 2019

/rebuild

@libgit2-azure-pipelines
Copy link
Copy Markdown

Sorry @pks-t, I was not able to find any builds to requeue.

@pks-t
Copy link
Copy Markdown
Member

pks-t commented Jun 14, 2019

Huh. Not even rebuilding works. Bummer

@tiennou
Copy link
Copy Markdown
Contributor

tiennou commented Jun 14, 2019

@pks-t
Copy link
Copy Markdown
Member

pks-t commented Jun 14, 2019

Cool, thanks @tiennou!

@ethomson
Copy link
Copy Markdown
Member Author

Mhh. It's unfortunate that VSTS deletes the latest build on still existing pull requests :/ Makes it impossible to see what's caused the error without a rebuild

Yeah, I need to fix this so that we retain builds >30 days.

@ethomson ethomson force-pushed the ethomson/warnings branch 4 times, most recently from bf20e94 to 599bbde Compare June 15, 2019 22:53
@ethomson
Copy link
Copy Markdown
Member Author

So we're now warning-free on all our core platforms (with the exception of xdiff) and I've enabled /WX (the equivalent of -Werror) on MSVC and -Werror on mingw.

For xdiff, there are warnings on Windows, largely due to LP vs LLP differences. Fixing them here would be a lot of code churn, so instead, I'd like to work with core git itself to ensure that we have a shared implementation that's warning-free on all platforms. As a result, I've disabled /WX (ie, just allowed the warnings without promoting them to errors) for the xdiff files. This will ensure that the rest of libgit2 stays warning free while we work with git to update xdiff.

@ethomson ethomson added the 1.0 label Jun 15, 2019
@ethomson
Copy link
Copy Markdown
Member Author

I'd love to get this merged reasonably soon, so that we don't accrue more warnings as time goes on. 😀 But I'll leave this open for a bit longer to make sure that everyone has some time to get 👀 on it.

Copy link
Copy Markdown
Member

@pks-t pks-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, forgot to actually publish my comments a few days ago

Comment thread CMakeLists.txt
ELSE()
ENABLE_WARNINGS(format)
ENABLE_WARNINGS(format-security)
DISABLE_WARNINGS(documentation-deprecated-sync)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this flag? Shouldn't we keep on setting this for both platforms?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mingw fails with cc1.exe: warning: unrecognized command line option '-Wno-documentation-deprecated-sync'. This is despite cmake believing that it's supported:

-- Performing Test IS_WNO_DOCUMENTATION_DEPRECATED_SYNC_SUPPORTED
-- Performing Test IS_WNO_DOCUMENTATION_DEPRECATED_SYNC_SUPPORTED - Success

(sigh.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this one seems to be very peculiar. I've noticed several times that it's popping up in CMake logs when there's compiler errors. Maybe we should just drop that flag altogether? Does any modern platform support it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also:

 ~ $ gcc -Wdocumentation-deprecated-sync
gcc: error: unrecognized command line option '-Wdocumentation-deprecated-sync'
gcc: fatal error: no input files
compilation terminated.
 ~ $ gcc -Wno-documentation-deprecated-sync
gcc: fatal error: no input files
compilation terminated.

It recognizes that it doesn't know it in the positive case, but it doesn't notice in the negative one. Maybe it's a bug in GCC?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

googling suggests that clang supports it...? Let's see what happens without it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, clang is definitely unhappy. We certainly could add the GIT_DEPRECATED macro back to add that attribute in, but that still seemed rather heavy-handed today.

It looks like gcc is perfectly happy with or without that option, though. We should just add that flag for clang...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sigh Yeah, I agree that it'd be too heavy-handed. With so many deprecations going on, users would probably get overwhelmed with a huge amount of warnings. Not much of a fan of adding compiler-specific flags either, but if that's the only way forward then let's do that?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread deps/zlib/adler32.c
z_off64_t len2;
{
return adler32_combine_(adler1, adler2, len2);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I do expect that this will creep in again when updating zlib in the future, though

@ethomson ethomson changed the title WIP: remove warnings Remove warnings Jun 24, 2019
@ethomson ethomson force-pushed the ethomson/warnings branch from 599bbde to 6c0a76d Compare June 24, 2019 13:58
@pks-t
Copy link
Copy Markdown
Member

pks-t commented Jun 24, 2019

By the way, you also need to rebase ;)

ethomson added 8 commits June 24, 2019 15:00
Our progress information messages are short (and bounded by their format
string), cast the length to int for callers.
Ensure that the server has not sent us overly-large sideband messages
(ensure that they are no more than `INT_MAX` bytes), then cast to `int`.
@ethomson ethomson force-pushed the ethomson/warnings branch 2 times, most recently from 2b326ba to 1393d78 Compare June 24, 2019 15:04
Copy link
Copy Markdown
Member

@pks-t pks-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I only skipped over some of that code, but from a glance it looks good to me.

Comment thread src/merge.c Outdated
git_error_set(GIT_ERROR_MERGE, "merged file contents too large for index");
error = -1;
goto done;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure, I can't remember how this looked before. Is this already the updated version? Cannot see any "outdated" marker.

ethomson added 12 commits June 24, 2019 17:27
Move `git_win32__file_attribute_to_stat` to a regular function instead
of an inlined function.  This helps avoid header ordering issues and
declarations.
For MSVC, support warnings as errors by providing the /WX compiler
flags.  (/WX is the moral equivalent of -Werror.)

Disable warnings as errors ass part of xdiff, since it contains
warnings.  But as a component of git itself, we want to avoid skew and
keep our implementation as similar as possible to theirs.  We'll work
with upstream to fix these issues, but in the meantime, simply let those
continue to warn.
RtlCaptureStackBackTrace is well-defined in Windows, no need to redefine
it.
MinGW uses gcc, which expects POSIX formatting for printf, but uses the
Windows C library, which uses its own format specifiers.  Therefore, it
gets confused about format specifiers.  Disable warnings for format
specifiers.
MinGW does not define DWORD_MAX.  Specify it when it's not defined.
GetProcAddress is prototyped to return a `FARPROC`, which is meant to be
a generic function pointer.  It's literally `int (FAR WINAPI * FARPROC)()`
which gcc complains if you attempt to cast to a `void (*)(GIT_SRWLOCK *)`.
Cast to a `void *` before casting to avoid warnings about the arguments.
GetProcAddress is prototyped to return a `FARPROC`, which is meant to be
a generic function pointer.  It's literally `int (FAR WINAPI * FARPROC)()`
which gcc complains if you attempt to cast to a `void (*)(GIT_SRWLOCK *)`.
Cast to a `void *` before casting to avoid warnings about the arguments.
Add the `-Wno-documentation-deprecated-sync` switch when compiling with
clang, since our documentation adds `deprecated` markers, but we do not
add the deprecation attribute in the code itself.  (ie, the code is out
of sync with the docs).

In fact, we do not _want_ to mark these items as deprecated in the code,
at least not yet, as we are not quite ready to bother our end-users with
this since they're not going away.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants