-
Notifications
You must be signed in to change notification settings - Fork 684
api: add OIIO_NODISCARD_ERROR to ImageOutput methods #5201
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
Changes from 1 commit
3ead3a8
e092be1
ac22aaa
2334d18
0ab82c6
bb5e9bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -187,7 +187,7 @@ time_write_image() | |||||||
| OIIO_ASSERT(out); | ||||||||
| bool ok = out->open(output_filename, outspec); | ||||||||
| OIIO_ASSERT(ok); | ||||||||
| out->write_image(bufspec.format, &buffer[0]); | ||||||||
| (void)out->write_image(bufspec.format, &buffer[0]); | ||||||||
|
Collaborator
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. Maybe?
Suggested change
Collaborator
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 wrote OIIO_ASSERT, but probably |
||||||||
| } | ||||||||
|
|
||||||||
|
|
||||||||
|
|
@@ -203,7 +203,7 @@ time_write_scanline_at_a_time() | |||||||
| size_t pixelsize = outspec.nchannels * sizeof(float); | ||||||||
| imagesize_t scanlinesize = outspec.width * pixelsize; | ||||||||
| for (int y = 0; y < outspec.height; ++y) { | ||||||||
|
Collaborator
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. You assign the result to ok, but ok isn't actually used anywhere. I think that it would be better if you had an OIIO_ASSERT(ok) (or OIIO_CONTRACT_ASSERT, I guess) after the loop. And the loop should probably terminate as soon as there's an error, say: This file is a bunch of unit tests, so it's not important to issue meaningful error messages with errorfmt or anything like that. But it is a test, so we should at least have an assertion to let us know that it's not really successfully testing the thing that we think it's testing. I'm only writing this comment here, but I think all of the changes in this file should follow a similar pattern. |
||||||||
| out->write_scanline(y + outspec.y, outspec.z, bufspec.format, | ||||||||
| (void)out->write_scanline(y + outspec.y, outspec.z, bufspec.format, | ||||||||
|
Collaborator
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. Maybe |
||||||||
| &buffer[scanlinesize * y]); | ||||||||
| } | ||||||||
| } | ||||||||
|
|
@@ -221,7 +221,7 @@ time_write_64_scanlines_at_a_time() | |||||||
| size_t pixelsize = outspec.nchannels * sizeof(float); | ||||||||
| imagesize_t scanlinesize = outspec.width * pixelsize; | ||||||||
| for (int y = 0; y < outspec.height; y += 64) { | ||||||||
| out->write_scanlines(y + outspec.y, | ||||||||
| (void)out->write_scanlines(y + outspec.y, | ||||||||
| std::min(y + outspec.y + 64, | ||||||||
| outspec.y + outspec.height), | ||||||||
| outspec.z, bufspec.format, | ||||||||
|
|
@@ -245,10 +245,10 @@ time_write_tile_at_a_time() | |||||||
| for (int z = 0; z < outspec.depth; z += outspec.tile_depth) { | ||||||||
| for (int y = 0; y < outspec.height; y += outspec.tile_height) { | ||||||||
| for (int x = 0; x < outspec.width; x += outspec.tile_width) { | ||||||||
| out->write_tile(x + outspec.x, y + outspec.y, z + outspec.z, | ||||||||
| bufspec.format, | ||||||||
| &buffer[scanlinesize * y + pixelsize * x], | ||||||||
| pixelsize, scanlinesize, planesize); | ||||||||
| (void)out->write_tile(x + outspec.x, y + outspec.y, z + outspec.z, | ||||||||
|
Collaborator
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. Same here, maybe more like I guess I'm superstitious about ignoring the return code, that's what we're trying to be caching. Even though this is a test... what better time to catch a problem then when we're testing? |
||||||||
| bufspec.format, | ||||||||
| &buffer[scanlinesize * y + pixelsize * x], | ||||||||
| pixelsize, scanlinesize, planesize); | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
|
|
@@ -268,11 +268,11 @@ time_write_tiles_row_at_a_time() | |||||||
| imagesize_t scanlinesize = outspec.width * pixelsize; | ||||||||
| for (int z = 0; z < outspec.depth; z += outspec.tile_depth) { | ||||||||
| for (int y = 0; y < outspec.height; y += outspec.tile_height) { | ||||||||
| out->write_tiles(outspec.x, outspec.x + outspec.width, | ||||||||
| y + outspec.y, y + outspec.y + outspec.tile_height, | ||||||||
| z + outspec.z, z + outspec.z + outspec.tile_depth, | ||||||||
| bufspec.format, &buffer[scanlinesize * y], | ||||||||
| pixelsize /*xstride*/, scanlinesize /*ystride*/); | ||||||||
| (void)out->write_tiles(outspec.x, outspec.x + outspec.width, | ||||||||
|
Collaborator
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. here, too |
||||||||
| y + outspec.y, y + outspec.y + outspec.tile_height, | ||||||||
| z + outspec.z, z + outspec.z + outspec.tile_depth, | ||||||||
| bufspec.format, &buffer[scanlinesize * y], | ||||||||
| pixelsize /*xstride*/, scanlinesize /*ystride*/); | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
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.
I think you should also set ok=false so that the function's return value indicates that something went wrong and that we don't overwrite the real file (at this point we are writing to a temporary file, and will, later i the function, replace the destination file only if everything appeared to go right).