Skip to content
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

Merged
merged 9 commits into from
Apr 29, 2022
Merged

Various non-critical fixes #208

merged 9 commits into from
Apr 29, 2022

Conversation

masatake
Copy link
Contributor

Close #206.

I introduced -Wall option in this pull request.
As the result, we'll get more warnings.

@masatake masatake requested a review from dilinger April 29, 2022 03:08
dilinger
dilinger previously approved these changes Apr 29, 2022
@dilinger dilinger dismissed their stale review April 29, 2022 04:12

That did not work how I wanted it to work :(

@masatake
Copy link
Contributor Author

That did not work how I wanted it to work :(

???
Which commit are you talking about?

print.c Outdated Show resolved Hide resolved
arg.c Outdated Show resolved Hide resolved
@dilinger
Copy link
Contributor

That did not work how I wanted it to work :(

??? Which commit are you talking about?

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.

@dilinger
Copy link
Contributor

#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}
Copy link

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?

Copy link
Contributor Author

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.

Copy link

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) \
Copy link

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.

Copy link
Contributor Author

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?

Copy link

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) \
Copy link

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.

Copy link
Contributor Author

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?

@masatake
Copy link
Contributor Author

masatake commented Apr 29, 2022

@dilinger,

#211 for my suggested fill_portmap change.

You know what I want!
Allow me to cherry-pick your change so we can close #206 with this pull request.

masatake and others added 9 commits April 29, 2022 18:12
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>
Copy link

@BenBE BenBE left a 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).

@masatake
Copy link
Contributor Author

@BenBE, thank you for reviewing.

Copy link
Contributor

@dilinger dilinger left a comment

Choose a reason for hiding this comment

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

Looks good!

@masatake masatake merged commit 84d159d into lsof-org:master Apr 29, 2022
@masatake
Copy link
Contributor Author

Thank you for revieiwng.

This pull request was closed.
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.95.0: compile time warnings
3 participants