Skip to content

Sundry small cleanups#8199

Merged
poettering merged 9 commits intosystemd:masterfrom
keszybz:small-things
Feb 19, 2018
Merged

Sundry small cleanups#8199
poettering merged 9 commits intosystemd:masterfrom
keszybz:small-things

Conversation

@keszybz
Copy link
Member

@keszybz keszybz commented Feb 16, 2018

No description provided.

This usually is very annoying to users who then cannot log in, so
make sure we always warn if that happens (selinux, or whatever other reason).

This reverts a790812.
void *data, \
void *userdata) { \
\
int function(GENERIC_PARSER_ARGS) { \
Copy link
Contributor

@sourcejedi sourcejedi Feb 16, 2018

Choose a reason for hiding this comment

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

Hmm, should we err on the side of keeping the argument list visible in this function definition, like the .c files? GENERIC_PARSER_ARGS works nicely in the big list of function declarations, but maybe we shouldn't use it outside of that. We could even #undef it immediately after the declarations.

Copy link
Member Author

Choose a reason for hiding this comment

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

The macro is defined just a few lines above, so I think it is OK to also use the macro here.

Copy link
Contributor

Choose a reason for hiding this comment

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

ehh. I'm not used to reading function definitions that way.

Just having #undef GENERIC_PARSER_ARGS somewhere would make me happier. It communicates the point made in the commit message, that we don't expect people to remember it. If you think the #undef would look ok placed after these two function definitions, then I defer to submitters judgement.

BTW apologies for clicking the wrong button, I was trying to do a full review from the start.

Copy link
Member Author

Choose a reason for hiding this comment

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

It'd need to be undefined after DEFINE_CONFIG_PARSE_ENUM is used, so there doesn't seem to be a nice way to do this.

Copy link
Contributor

Choose a reason for hiding this comment

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

ohh. sorry.

unlinkat(dirfd(d), de->d_name, 0);
if (unlinkat(dirfd(d), de->d_name, 0) < 0)
log_warning("Failed to remove /run/systemd/seats/%s: %m",
de->d_name);
Copy link
Contributor

Choose a reason for hiding this comment

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

everybody's favourite task: adding error handling.

We've got a different approach for each of the three calls in this commit... and each call looks like it's filling the exact same role.

The journald one sounds a bit worrying, if it could later restore a stale stream with the wrong fd? Should the journald one be raised to LOG_WARNING as well?

I'm not really worried about the udev one being ignored.

Copy link
Member Author

Choose a reason for hiding this comment

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

I made them both log_warning now.

assert_se(utf8_n_codepoints("zażółcić gęślą jaźń") == 19);
assert_se(utf8_n_codepoints("串") == 1);
assert_se(utf8_n_codepoints("") == 0);
assert_se(utf8_n_codepoints("\xF1") == (size_t) -1);
Copy link
Member

Choose a reason for hiding this comment

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

hey, come on! you totally missed out on the chance to count the codepoints in an emoji infested string!

I mean, emojis! EMOJIS!

@poettering
Copy link
Member

lgtm (except of course the massive missed opportunity of testing emoji strings in the utf8_n_codepoints() tests.)

@poettering poettering added util-lib good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed labels Feb 16, 2018
Copy link
Contributor

@sourcejedi sourcejedi left a comment

Choose a reason for hiding this comment

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

Afraid I bounced off "do not initialize join_controllers by default", but I was able to review everything else.

Thanks for pulling in my suggested comment fix, and this looks nice generally. I have two sundry comments.

assert(lvalue);
assert(rvalue);

arg_join_controllers = strv_free_free(arg_join_controllers);
Copy link
Contributor

@sourcejedi sourcejedi Feb 16, 2018

Choose a reason for hiding this comment

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

Equally, having to use arg_join_controllers directly instead of through data was a sign we were being a bit weird. Nice cleanup :).

void *data, \
void *userdata) { \
\
int function(GENERIC_PARSER_ARGS) { \
Copy link
Contributor

Choose a reason for hiding this comment

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

ehh. I'm not used to reading function definitions that way.

Just having #undef GENERIC_PARSER_ARGS somewhere would make me happier. It communicates the point made in the commit message, that we don't expect people to remember it. If you think the #undef would look ok placed after these two function definitions, then I defer to submitters judgement.

BTW apologies for clicking the wrong button, I was trying to do a full review from the start.

@yuwata yuwata added ci-fails/needs-rework 🔥 Please rework this, the CI noticed an issue with the PR and removed good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed labels Feb 19, 2018
@yuwata
Copy link
Member

yuwata commented Feb 19, 2018

The CIs fail to start systemd...

[    3.437497] traps: systemd[1] general protection ip:7fbe50a5158a sp:7fff55dbeaa8 error:0 in libc-2.23.so[7fbe509b2000+1c0000]
[    3.441074] systemd[1]: Caught <SEGV>, dumped core as pid 326.
[    3.442023] systemd[1]: Freezing execution.

Coverity now started warning about this ("Calling unlinkat without checking
return value (as is done elsewhere 12 out of 15 times).", and it is right:
most of the time we should at list print a log message so people can figure
out something is wrong when this happens.

v2:
- use warning level in journald too (this is unlikely to happen ever, so it
  should be safe to something that is visible by default).
The arguments have to be indentical everywhere, so let's use a macro to
make things more readable. But only in the headers, in the .c files let's
keep them verbose so that it's easy to see the argument list.
config_parse_join_controllers would free the destination argument on failure,
which is contrary to our normal style, where failed parsing has no effect.
Moving it to shared also allows a test to be added.
We're moving towards unified cgroup hierarchy where this is not necessary.
This makes main.c a bit simpler.
Follow up for review of systemd#8184.
@keszybz
Copy link
Member Author

keszybz commented Feb 19, 2018

I fixed the important issue (lack of fancy shmancy unicode) and the other one (missing array terminator leading to a crash).

@keszybz keszybz removed the ci-fails/needs-rework 🔥 Please rework this, the CI noticed an issue with the PR label Feb 19, 2018
@poettering poettering merged commit 30663b6 into systemd:master Feb 19, 2018
@keszybz keszybz deleted the small-things branch February 19, 2018 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

4 participants