-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gcc 11 cleanup #12237
gcc 11 cleanup #12237
Conversation
Not sure if the @felixdoerre Shouldn't we check the return value of |
Yes, probably we should treat a failure in |
A bit more detail. Not sure where the warning in
The extern declaration in
The warnings in
|
@felixdoerre All right, will open a PR once this is merged. |
Aren't we just hiding the real problems with the above patch? I can also compile if I simply disable the In particular, I do not like the idea of using a generic |
BTW: You do not have to make another PR, just add new commits (even forced ones) to the same branch (AttilaFueloep:zfs-icp-gcc11). |
zfs/module/icp/api/kcf_miscapi.c Lines 44 to 49 in 83ba91a
So a
PRs should be limited to fixing distinct problems. |
As a general rule we have tried to avoid using I briefly looked at the |
Given the weird location of the arrow ( |
Well, I could introduce a new struct, say |
Managed to get rid of the |
Not bad, but hurts my brain optimizer. :-) Did you try a cast to Or, at least, use And in Anyway, this may be just me doing yet another bikeshedding. :-( Thanks for your work, @AttilaFueloep ! |
Yep.
Yeah, good idea.
While I generally agree, this would involve refactoring the whole call chain, which I think is outside the scope of this PR. |
include/sys/dnode.h
Outdated
* This structure holds only the portable fields of a dnode_phys_t, i.e. | ||
* all fields but excluding the variable sized tail region. It is used to | ||
* calculate the HMAC of a dnode_phys_t in zio_crypt_do_dnode_hmac_updates(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems a little unfortunate to have to duplicate this. Could we embed it in the dnode_phys_t instead? Though I guess since it's on-disk it won't be changing very often.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was my concern and reasoning as well. I do type embedding frequently in Go but I failed to figure how to do it in C without requiring Microsoft extensions (gcc/clang -fms-extensions
flag). Even in C11 you can't have an anonymous struct member of a previously defined type. Am I missing something obvious here? Or are you thinking of doing some #define
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the cleanest way is to do something like
struct dnode_phys {
dnode_phys_core_t dn_core;
union {
...
}
}
The downside is that you have to change all the code that's accessing it to add .dn_core
:( . (And the "solution" to that of doing #define dn_type dn_core.dn_type
seems worse.)
I'm guessing that the compiler's complaint about the current code is that you have a dnode_phys_t*
that points to an array that is not large enough to hold a dnode_phys_t. I think the proposed solution is decent but I wonder if there's another way to do this. Maybe if we allocated a larger buffer to point to (might have to be on the heap due to the linux kernel's limited stack space). That would be a little slower but it might not be significantly so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The downside is that you have to change all the code that's accessing it to add
.dn_core
:( . (And the "solution" to that of doing#define dn_type dn_core.dn_type
seems worse.)
Yeah, fully agree. It would be so nice if we could just say
struct dnode_phys {
struct dnode_phys_core;
union {
...
}
}
but well, maybe in ten years, using C23, that'll work. ;-)
I'm guessing that the compiler's complaint about the current code is that you have a
dnode_phys_t*
that points to an array that is not large enough to hold a dnode_phys_t.
Exactly, ‘dnode_phys_t {aka struct dnode_phys}[0]’ is partly outside array bounds
. The full warning is here at the bottom.
Maybe if we allocated a larger buffer to point to
That didn't occur to me, but your right, using a dnode_phys_t
and just limiting the HMAC calculation to the first 64 bytes of that may be a cleaner solution. IIRC the stack size in Linux is 16k and a dnode_phys_t
is 512 bytes, so limited stack space shouldn't be a concern. The only drawbacks I can see is 448 more bytes on the stack and maybe slightly less clearer code. I'll push a changed version. Which approach to choose I leave up to you, I'm fine either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unfortunate we need to use the additional space on the stack for this, but I agree it shouldn't be a problem here. Things are a bit tighter on i386 with uses 8k stacks, but I believe we'll still be OK there as well. This does seem like the cleanest way to handle this to me.
All right. I'll hold-up squashing until a second reviewer had a chance to look at it. |
Thanks for doing that, looks great! |
Compiling with gcc 11.1.0 produces three new warnings. Change the code slightly to avoid them. Signed-off-by: Attila Fülöp <[email protected]> Closes openzfs#12130 Closes openzfs#12188
4416af2
to
e2b1d0e
Compare
My pleasure. Squashed, rebased and updated commit comment. |
Compiling with gcc 11.1.0 produces three new warnings. Change the code slightly to avoid them. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Matthew Ahrens <[email protected]> Signed-off-by: Attila Fülöp <[email protected]> Closes #12130 Closes #12188 Closes #12237
Compiling with gcc 11.1.0 produces three new warnings. Change the code slightly to avoid them. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Matthew Ahrens <[email protected]> Signed-off-by: Attila Fülöp <[email protected]> Closes openzfs#12130 Closes openzfs#12188 Closes openzfs#12237
Compiling with gcc 11.1.0 produces three new warnings. Change the code slightly to avoid them. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Matthew Ahrens <[email protected]> Signed-off-by: Attila Fülöp <[email protected]> Closes openzfs#12130 Closes openzfs#12188 Closes openzfs#12237
Compiling with gcc 11.1.0 produces three new warnings. Change the code slightly to avoid them. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Matthew Ahrens <[email protected]> Signed-off-by: Attila Fülöp <[email protected]> Closes #12130 Closes #12188 Closes #12237
Compiling with gcc 11.1.0 produces three new warnings. Change the code slightly to avoid them. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Matthew Ahrens <[email protected]> Signed-off-by: Attila Fülöp <[email protected]> Closes openzfs#12130 Closes openzfs#12188 Closes openzfs#12237
Motivation and Context
Building with gcc 11.1.0 fails due to warnings.
Description
Disable false positive warnings, fix a wrong prototype.
Closes #12130
Closes #12188
How Has This Been Tested?
Just a local build.
Types of changes
Checklist:
Signed-off-by
.