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

Replace readdir_r #1641

Merged
merged 28 commits into from
Jul 17, 2020
Merged

Conversation

kripton
Copy link
Member

@kripton kripton commented May 17, 2020

This PR replaces the deprecated readdir_r with the non-deprecated readdir.
A unit test is added to make sure we don't break anything. Tested on the old readdir_r and the new code.

Open for discussions :)

@kripton
Copy link
Member Author

kripton commented May 17, 2020

Oh, forgot: Fixes #1055

@kripton
Copy link
Member Author

kripton commented May 17, 2020

Forgot another thing: I also wanted to revert #1168. That might lead to more warning being shown, so not tested yet. Will do so later. So please don't merge yet.

@kripton
Copy link
Member Author

kripton commented May 17, 2020

Okay, Travis tests are failing due to out-of-tree builds. I'll check how other tests are handling test data

@kripton
Copy link
Member Author

kripton commented May 22, 2020

Okay, I'd say this is ready for review & comments. New unit test is passing on Travis, existing tests are flaky and currently sometimes fail non macOS. Doesn't seem to be related to these changes.

Copy link
Member

@peternewman peternewman left a comment

Choose a reason for hiding this comment

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

A few comments

common/file/UtilTest.cpp Outdated Show resolved Hide resolved
common/file/UtilTest.cpp Show resolved Hide resolved
configure.ac Show resolved Hide resolved
common/file/Util.cpp Show resolved Hide resolved
@peternewman peternewman added this to the 0.10.8 milestone Jun 3, 2020
@kripton
Copy link
Member Author

kripton commented Jun 13, 2020

@peternewman : All comments addressed (code changed or reasoning added ;)). Ready for a new round of review

@kripton
Copy link
Member Author

kripton commented Jun 13, 2020

Oh, right, linting pointed out some stuff I saw just now. Will also take care of that

@kripton kripton force-pushed the ReplaceReaddir_r branch from 9a4ffc7 to e6e6d6a Compare June 13, 2020 08:42
@kripton
Copy link
Member Author

kripton commented Jun 13, 2020

All lint fixes done and rebased onto latest 0.10 branch

Copy link
Member

@peternewman peternewman left a comment

Choose a reason for hiding this comment

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

A few comments and improvements if you wouldn't mind.

common/file/UtilTest.cpp Outdated Show resolved Hide resolved
common/file/Util.cpp Show resolved Hide resolved
common/file/UtilTest.cpp Outdated Show resolved Hide resolved
Copy link
Member

@peternewman peternewman left a comment

Choose a reason for hiding this comment

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

Two more comments

common/file/UtilTest.cpp Outdated Show resolved Hide resolved
common/file/UtilTest.cpp Outdated Show resolved Hide resolved
@peternewman
Copy link
Member

Apologies for the flurry of commits @kripton but I've now got Codespell working again on Travis which would need to be sorted to merge this anyway, hope you don't mind.

@kripton
Copy link
Member Author

kripton commented Jun 26, 2020

No need to excuse for the Travis-fixing commits.
I've taken care of your comments.
About your comment on:

I'm unclear what a successful opendir call and an errorno value would mean, although it seems to say it shouldn't.

As far as I understand: If opendir fails, it'll return NULL and set errno so one can see why it failed. If it succeeds, it returns a value and probably leaves errno untouched. However, it could also set a value. But since there is no errno-value for "success", it probably doesn't. So if a value is returned, just ignore errno. I wouldn't know which value to ASSERT here. But before calling readdir, I set it to 0 to make sure it has a defined value.
I agree that a successful opendir WITH an value in errno would mean. But ASSERTING it to be 0 when the manuals says it could be changed seems a bit risky to me.

Copy link
Member

@peternewman peternewman left a comment

Choose a reason for hiding this comment

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

I agree that a successful opendir WITH an value in errno would mean. But ASSERTING it to be 0 when the manuals says it could be changed seems a bit risky to me.

Ah yeah true. I see your point.

If we can have a comment briefly explaining why it's being set to 0 (due to the NULL thing), and then one other style comment and we're good to go thanks.

Feel free to take some credit for this and other bits you've done in AUTHORS if you'd like, and add a line to NEWS (or I can do the latter).

common/file/UtilTest.cpp Outdated Show resolved Hide resolved
common/file/UtilTest.cpp Outdated Show resolved Hide resolved
common/file/Util.cpp Show resolved Hide resolved
common/file/Util.cpp Show resolved Hide resolved
@kripton
Copy link
Member Author

kripton commented Jul 7, 2020

Hi @peternewman , I've added comments regarding errno = 0, changed the ifs to else ifs and modified NEWS and AUTHORS. Feel free to modify the two latter files if you prefer a different wording :)

Copy link
Member

@peternewman peternewman left a comment

Choose a reason for hiding this comment

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

Sorry a handful of minor style bits I'd somehow missed before.

Thanks for fixing Codespell too!

common/file/UtilTest.cpp Outdated Show resolved Hide resolved
common/file/UtilTest.cpp Outdated Show resolved Hide resolved
common/file/UtilTest.cpp Outdated Show resolved Hide resolved
common/file/UtilTest.cpp Outdated Show resolved Hide resolved
common/file/UtilTest.cpp Outdated Show resolved Hide resolved
common/file/UtilTest.cpp Outdated Show resolved Hide resolved
common/file/UtilTest.cpp Outdated Show resolved Hide resolved
@kripton
Copy link
Member Author

kripton commented Jul 7, 2020

One thing I noticed: Travis build on macOS fails due to newer libmicrohttpd. I'm experiencing the same on my Gentoo Linux machine. v0.9.70 is fine, v0.9.71 fails.

@peternewman
Copy link
Member

peternewman commented Jul 7, 2020

One thing I noticed: Travis build on macOS fails due to newer libmicrohttpd. I'm experiencing the same on my Gentoo Linux machine. v0.9.70 is fine, v0.9.71 fails.

Oops, that's embarrassing, I'd just assumed it was the tests that are always flaky on Mac and hadn't looked yet.

Looks like it's someone else who doesn't understand semver! See for example https://bugs.archlinux.org/task/67208 which links to https://git.gnunet.org/libmicrohttpd.git/commit/?id=6347f514aa2388e774d5bf356df8046864e5f73c and their fix seems to be here: systemd/systemd@d17eabb#diff-2d7e61049e387b011a9df20244a7922d

Do you want to chuck all the necessary #ifdef cotton wool in, either in this PR or another one? We'd normally deal with it like this:

string LibUsbAdaptor::ErrorCodeToString(const int error_code) {
#ifdef HAVE_LIBUSB_ERROR_NAME
return libusb_error_name(error_code);
#else
ostringstream str;
str << "Error code " << error_code;
return str.str();
#endif // HAVE_LIBUSB_ERROR_NAME
}

See also: xbmc/xbmc#18131 and https://git.gnunet.org/gnunet.git/tree/src/include/gnunet_mhd_compat.h

@kripton
Copy link
Member Author

kripton commented Jul 8, 2020

Yep, that libmicrohttpd-changes are a pity. I'll create a separate PR for that, feel free to create an issue to track the build breakage.

@kripton
Copy link
Member Author

kripton commented Jul 8, 2020

@peternewman I think I've done all changes + pushed now :) Let's see what Travis says, despite the expected-for-now failures on macOS

@kripton
Copy link
Member Author

kripton commented Jul 8, 2020

#1650 created to track the libmicrohttpd build failures. However, now Travis fails on macOS due to some python file conflicts.....

@peternewman
Copy link
Member

However, now Travis fails on macOS due to some python file conflicts.....

From what I can see, it's trying to upgrade the Homebrew packages, so postgis pulls in numpy via Homebrew but because numpy is already installed via pip it fails. Hopefully Travis will get their act together soon, or I can force merge it, or manually delete files/uninstall from pip or something...

Copy link
Member

@peternewman peternewman 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 for this one too!

@peternewman peternewman merged commit e2cd699 into OpenLightingProject:0.10 Jul 17, 2020
@kripton kripton deleted the ReplaceReaddir_r branch January 29, 2021 22:53
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.

2 participants