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

assorted minor source cleanup #5918

Merged
merged 6 commits into from Apr 28, 2024
Merged

Conversation

garlick
Copy link
Member

@garlick garlick commented Apr 28, 2024

This fixes assorted source hygiene issues, nothing major.

Problem: czmq destructors are inconsistent with regard to
1) checking the 'arg' for NULL before dereferencing, and
2) setting '*arg' to NULL after destruction.

Adjust a few functions.
This probably has no effect but does improve consistency.
Problem: when run under valgrind, the libsubprocess command unit
test throws the following error:

ok 150 - flux_cmd_stringify on empty cmd works
==3429631== Invalid read of size 1
==3429631==    at 0x484FBD4: strcmp (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==3429631==    by 0x10CAFC: mystrcmp (tap.c:100)
==3429631==    by 0x10CAFC: mystrcmp (tap.c:99)
==3429631==    by 0x10CAFC: is_at_loc (tap.c:110)
==3429631==    by 0x10B7B4: test_stringify (command.c:226)
==3429631==    by 0x10AA5B: main (command.c:459)
==3429631==  Address 0x4abe1c0 is 0 bytes after a block of size 0 alloc'd
==3429631==    at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==3429631==    by 0x10DEAB: flux_cmd_stringify (command.c:484)
==3429631==    by 0x10B76D: test_stringify (command.c:223)
==3429631==    by 0x10AA5B: main (command.c:459)
==3429631==

From malloc(3):
  If nmemb or size is 0,  then  calloc()  returns either  NULL,  or a
  unique pointer value that can later be successfully passed to free().

I think when the command is empty, argz_len is zero, and calloc()
returns this unique pointer, which we then dereference.

Rework the function to work like the test expects.
Problem: eventlog_entry_parse() unnecessarily calls json_unpack()
twice.

It may not have much impact but since this function is called on
performance critical paths, consolidate the calls.
Problem: broker overlay includes ccan/ptrint.h but doesn't use it.

Drop #include directive.
Problem: a function call with a long parameter list is
not broken to one per line, as per project norms.

Fix line breaks.
Problem: autogen.sh complains of a typo.

t/Makefile.am:1058: warning: variable 'job_manager_plugin_offline_la_SOURCES' is defined but no program or
t/Makefile.am:1058: library has 'job_manager_plugin_offline_la' as canonical name (possible typo)

Fix typo.
The test plugin seems to be built anyway so this is just cleanup.
Copy link
Contributor

@grondo grondo left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@garlick
Copy link
Member Author

garlick commented Apr 28, 2024

Hmm coverage builder got stuck here again. Restarting.

2024-04-28T16:50:47.2335710Z expecting success: 
2024-04-28T16:50:47.2336173Z 	grep -v reject_id validate-plugin.out | grep -v foo \
2024-04-28T16:50:47.2336535Z 	    | sed -e "s/.*jobid=//" >valid_ids &&
2024-04-28T16:50:47.2336799Z 	test_debug "cat valid_ids" &&
2024-04-28T16:50:47.2337359Z 	test 4 -eq $(wc -l <valid_ids)
2024-04-28T16:50:47.2337563Z 
2024-04-28T16:50:47.2337982Z not ok 45 - job-manager: get job IDs of valid jobs
2024-04-28T16:50:47.2337988Z 
2024-04-28T16:50:47.2338089Z expecting success: 
2024-04-28T16:50:47.2338535Z 	while ! test_inactive $(cat valid_ids); do echo retry; sleep 0.1; done
2024-04-28T16:50:47.2338541Z 
2024-04-28T16:50:47.2338746Z retry
2024-04-28T16:50:47.2339200Z retry
2024-04-28T16:50:47.2339650Z retry
2024-04-28T16:50:47.2340088Z retry

Copy link

codecov bot commented Apr 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.32%. Comparing base (fa7a09a) to head (8e2f4db).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5918      +/-   ##
==========================================
+ Coverage   83.29%   83.32%   +0.02%     
==========================================
  Files         514      514              
  Lines       82957    82960       +3     
==========================================
+ Hits        69100    69125      +25     
+ Misses      13857    13835      -22     
Files Coverage Δ
src/broker/broker.c 78.21% <100.00%> (+0.02%) ⬆️
src/broker/overlay.c 84.08% <ø> (+0.40%) ⬆️
src/broker/runat.c 79.65% <100.00%> (ø)
src/common/libeventlog/eventlog.c 87.85% <100.00%> (-0.34%) ⬇️
src/common/libpmi/simple_server.c 84.41% <100.00%> (+0.50%) ⬆️
src/common/librlist/rlist.c 85.70% <100.00%> (-0.06%) ⬇️
src/common/librouter/msg_hash.c 95.74% <100.00%> (-0.09%) ⬇️
src/common/libsubprocess/command.c 71.04% <100.00%> (+0.19%) ⬆️
src/modules/job-list/idsync.c 68.96% <100.00%> (-2.57%) ⬇️
src/modules/kvs/cache.c 90.35% <100.00%> (ø)
... and 3 more

... and 12 files with indirect coverage changes

@mergify mergify bot merged commit bff958b into flux-framework:master Apr 28, 2024
35 checks passed
@garlick garlick deleted the misc_cleanup branch April 28, 2024 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants