Skip to content

Commit

Permalink
fixup! iiod-client: Send block dequeue request when previous one failed
Browse files Browse the repository at this point in the history
  • Loading branch information
pcercuei committed Jan 12, 2024
1 parent 1b1b85f commit a58629c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion iiod-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1718,7 +1718,7 @@ int iiod_client_dequeue_block(struct iio_block_pdata *block, bool nonblock)
/* Retrieve return code of enqueue */
ret = (int) iiod_io_wait_for_response(block->io);
if (ret < 0) {
if ((uint16_t)ret == 0) {
if (((unsigned int)ret & 0xffff) == 0) {
/* Low 16 bits are clear - the block wasn't enqueued. */
block->enqueued = false;

Expand Down

7 comments on commit a58629c

@catkira
Copy link
Contributor

Choose a reason for hiding this comment

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

do these versions behave differently?

@catkira
Copy link
Contributor

Choose a reason for hiding this comment

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

or is it just cosmetic to make the intention clearer?

@pcercuei
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not at all - but Codacy is stupid and said that (uint16_t)ret == 0 was always false.

@mhennerich
Copy link
Contributor

Choose a reason for hiding this comment

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

Not at all - but Codacy is stupid and said that (uint16_t)ret == 0 was always false.

Not sure - if we first check ret < 0, how can ret become 0 afterwards?

/* Retrieve return code of enqueue */
ret = (int) iiod_io_wait_for_response(block->io);
if (ret < 0) {
	if ((uint16_t)ret == 0) {

@pcercuei
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't be zero. We just check that the lower 16 bits are zero.

@catkira
Copy link
Contributor

@catkira catkira commented on a58629c Jan 12, 2024

Choose a reason for hiding this comment

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

I think both code versions behave the same
image
image

@catkira
Copy link
Contributor

Choose a reason for hiding this comment

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

but anyway, I think the new version is easier to read. I was just curious if I understood the casting wrong.

Please sign in to comment.