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

Remove extraneous casts to void #4377

Merged
merged 6 commits into from
Oct 10, 2023
Merged

Remove extraneous casts to void #4377

merged 6 commits into from
Oct 10, 2023

Conversation

eric-hughes-tiledb
Copy link
Contributor

@eric-hughes-tiledb eric-hughes-tiledb commented Sep 20, 2023

This PR removes a number of extraneous casts to void, though not all in the same way. It does not have a goal of removing all of extraneous casts.

The most frequent by far is to prevent unused variable warnings for function arguments that are not actually used. In this case changing to an anonymous argument solves the problem. It also indicates quite clearly that an argument isn't used. In some cases checks for the validity of unused arguments were also removed.

In some cases a variable declaration (argument or otherwise) were annotated with [[maybe_unused]]. This was most often the case where the code varies with preprocessor definitions. In a few cases some argument checks were promoted from assert to throwing exceptions when invalid..


TYPE: NO_HISTORY
DESC: Remove extraneous casts to void

Copy link
Contributor

@davisp davisp left a comment

Choose a reason for hiding this comment

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

Overall this looks straightforward. The only bit was when I read up on std::ignore and the docs say that it's behavior outside of std::tie is undefined not specified with a caveat that some folks are using it exactly as you are:

While the behavior of std::ignore outside of std::tie is not formally specified, some code guides recommend using std::ignore to avoid warnings from unused return values of [[nodiscard]] functions.

I don't know C++ enough to know whether the undefined unspecified bit is important, but I just recently fixed a UBSAN issue so it stuck out to me. Given that none of those changes are in public headers, I'm inclined to consider it fine if all of our CI runners pass.

+1. Will approve once CI is green.

@@ -1205,11 +1201,7 @@ ByteVecValue Dimension::map_from_uint64(

template <>
ByteVecValue Dimension::map_from_uint64<char>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Change Dimension* to Dimension&?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Out of scope for this PR. I've done some of that kind of thing before, and it tends to cascade throughout. That kind of change is best left to its own change set, where you can make all the changes needed in their own package.

@@ -201,11 +201,7 @@ uint64_t Domain::cell_num_per_tile() const {

template <>
int Domain::cell_order_cmp_impl<char>(
const Dimension* dim, const UntypedDatumView a, const UntypedDatumView b) {
// Must be var-sized
assert(dim->var_size());
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a big deal as I'm planning to change a lot of these implementations to std::string to prevent exactly this soon. This check might prevent someone using this function to process a CHAR datatype.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case this check was not only unnecessary but not even the quite the right check.

Copy link
Contributor

Choose a reason for hiding this comment

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

What would be the right check?

This PR removes a number of extraneous casts to void, though not all in the same way. It does not have a goal of removing all of extraneous casts.

The most frequent by far is to prevent unused variable warnings for function arguments that are not actually used. In this case changing to an anonymous argument solves the problem. It also indicates quite clearly that an argument isn't used. In some cases checks for the validity of unused arguments were also removed.

In some cases a variable declaration (argument or otherwise) were annotated with `[[maybe_unused]]`. This was most often the case where the code varies with preprocessor definitions.

In a few cases some argument checks were promoted from `assert` to throwing exceptions when invalid. A handful of ignored return values were replaced with `std::ignore`.
@eric-hughes-tiledb eric-hughes-tiledb force-pushed the eh/removed_unused_arguments branch from 947b9bc to 6f6e517 Compare October 5, 2023 17:01
Copy link
Contributor

@davisp davisp left a comment

Choose a reason for hiding this comment

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

+1

@KiterLuc KiterLuc merged commit ca08fdf into dev Oct 10, 2023
53 checks passed
@KiterLuc KiterLuc deleted the eh/removed_unused_arguments branch October 10, 2023 15:16
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.

3 participants