-
Notifications
You must be signed in to change notification settings - Fork 60
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
procstat: Fix bug with procstat compartments #2323
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,14 +50,13 @@ | |
xo_emit("{T:/%5s %-19s %4s %-40s}\n", "PID", "COMM", "CID", | ||
"CNAME"); | ||
if (procstat_getcompartments(procstat, kipp, &cccp, &ncomparts) != 0) | ||
goto out; | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is the only real fix FWIW. It's not unusual to say that the value of arguments passed by pointer is unchanged/undefined if a function fails. Or put another way, it is only assigned a defined value if the function succeeds and it is an error to use the value if the function fails. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good to me to just leave the inout pointers untouched if there's an error. The diff is also smaller this way. |
||
for (size_t i = 0; i < ncomparts; ++i) { | ||
xo_emit("{k:process_id/%5d/%d}", kipp->ki_pid); | ||
xo_emit(" {:command/%-19s/%s}", kipp->ki_comm); | ||
xo_emit(" {:cid/%4d/%zu}", cccp[i].ccc_id); | ||
xo_emit(" {:cname/%-40s/%s}", cccp[i].ccc_name); | ||
xo_emit("\n"); | ||
} | ||
out: | ||
free(cccp); | ||
} | ||
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.
Note that if you initialized
inbuf
toNULL
at the start of the function you could consolidate this down to a single label (but as a followup commit if you wanted to do that).