-
Notifications
You must be signed in to change notification settings - Fork 104
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
Various non-critical fixes #208
Conversation
That did not work how I wanted it to work :(
??? |
I was hoping that I could approve commits individually, but instead by clicking "approve" it approved the entire PR. Other than the fill_portmap thing, it all looks fine. |
#211 for my suggested fill_portmap change. |
@@ -18,7 +18,7 @@ CDEF= | |||
CDEFS= ${CDEF} ${CFGF} | |||
DEP= ${CFGD} ${CFGDN} | |||
INCL= ${DINC} | |||
CFLAGS= ${CDEFS} ${INCL} ${DEP} ${DEBUG} | |||
CFLAGS= -Wall ${CDEFS} ${INCL} ${DEP} ${DEBUG} |
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.
Why not put this in the (currently empty) CDEF
assignment below, which propagates to here anyway?
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 guess the original author introduced CDEF for allowing a user to add extra definition flags (-D) from the command line of make. So I didn't put '-Wall' to CDEF. Just guessing.
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 way those variables are handled right now they always override anything provided on the command line. Would have to be CDEFS?=
to allow overriding by the user.
#define TCPUDP_IPC_HASH(tp) ((int)(((((tp)->faddr \ | ||
+ (tp)->laddr, \ | ||
+ (tp)->laddr \ | ||
+ (tp)->fport \ | ||
+ (tp)->lport \ | ||
+ (tp)->proto) * 31415) >> 3) \ |
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.
Should use distinct prime factors (large, distinct) to minimize number of collisions. Currently this hash function has obvious collisions that can occur easily.
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.
Thank you.
However, in this pull request, I would like to focus on suppressing the warnings reported by the I compiler.
So, could you make a pull request after I merged this pull request?
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.
Can try to prepare one.
#define TCPUDP6_IPC_HASH(tp) ((int)((((TCPUDP6_IPC_ADDR_MK_INT(&(tp)->faddr) \ | ||
+ TCPUDP6_IPC_ADDR_MK_INT(&(tp)->laddr), \ | ||
+ TCPUDP6_IPC_ADDR_MK_INT(&(tp)->laddr) \ | ||
+ (tp)->fport \ | ||
+ (tp)->lport \ | ||
+ (tp)->proto) * 31415) >> 3) \ |
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.
Same remark as with the above UDP hash.
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.
Thank you.
However, in this pull request, I would like to focus on suppressing the warnings reported by the I compiler.
So, could you make a pull request after I merged this pull request?
bitwise & was used mistakenly. Fortunately, the mistake and this fix have no impact on output of lsof. Inspired by the issue lsof-org#206 reported by Tomasz Kłoczko (@kloczek). Signed-off-by: Masatake YAMATO <yamato@redhat.com>
There were typos in the code calculating hash values. The typos might break the flatness of hashtables where the endpoint information about locally used tcp/udp was stored. Theoretically, this fix may improve the performance of lsof with [+|-]E option. Inspired by the issue lsof-org#206 reported by Tomasz Kłoczko (@kloczek). Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Partially close lsof-org#206 reported by @kloczek. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
structure variables, "dummy_utmp" was defined just for getting the size of its member. It was not needed in run-time. Partially close lsof-org#206 reported by @kloczek. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
File static variables, "copyright", were defined multiple places. They were not referenced anywhere in lsof source code. It seems that the definitions were for embedding copyright notice to object files. However, modern build-systems eliminate unused text from object files. Therefore, the texts defined with "copyright" variables have no expected effect. Furthermore, they are harmful; they cause "unused variables" warnings reported by compilers as reported in lsof-org#206. Partially close lsof-org#206. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
This fix may not have any impact at run-time because the value is never referenced. This change is just for suppressing a compiler warning. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
The pm variable is only used if !defined(HASNORPC_H), so we should protect it with an #if. However, rather than doing that let's move it to the fill_portmap function itself. One less #if to mentally process.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
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.
Changes LGTM (sans hash function as per discussion in comments, PR will follow).
@BenBE, thank you for reviewing. |
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.
Looks good!
Thank you for revieiwng. |
Close #206.
I introduced -Wall option in this pull request.
As the result, we'll get more warnings.