Skip to content

api: apply OIIO_NODISCARD to color.h#5196

Merged
lgritz merged 3 commits into
AcademySoftwareFoundation:mainfrom
luna-y-kim:nodiscard-color-h
May 16, 2026
Merged

api: apply OIIO_NODISCARD to color.h#5196
lgritz merged 3 commits into
AcademySoftwareFoundation:mainfrom
luna-y-kim:nodiscard-color-h

Conversation

@luna-y-kim
Copy link
Copy Markdown
Contributor

@luna-y-kim luna-y-kim commented May 14, 2026

Description

Adds OIIO_NODISCARD and OIIO_NODISCARD_ERROR to color.h.
Deprecated functions are left unannotated.

Part of #4781

Assisted-by: Claude / Opus 4.7

Tests

No new tests, only attributes are added.

Checklist:

  • I have read the guidelines on contributions and code review procedures.
  • I have read the Policy on AI Coding Assistants
    and if I used AI coding assistants, I have an Assisted-by: TOOL / MODEL
    line in the pull request description above.
  • (N/A) I have updated the documentation if my PR adds features or changes
    behavior.
  • I am sure that this PR's changes are tested in the testsuite.
  • I have run and passed the testsuite in CI before submitting the
    PR, by pushing the changes to my fork and seeing that the automated CI
    passed there. (Exceptions: If most tests pass and you can't figure out why
    the remaining ones fail, it's ok to submit the PR and ask for help. Or if
    any failures seem entirely unrelated to your change; sometimes things break
    on the GitHub runners.)
  • My code follows the prevailing code style of this project and I
    fixed any problems reported by the clang-format CI test.
  • (N/A) If I added or modified a public C++ API call, I have also amended the
    corresponding Python bindings. If altering ImageBufAlgo functions, I also
    exposed the new functionality as oiiotool options.

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 14, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: luna-y-kim / name: Luna Kim (583a325)

@lgritz
Copy link
Copy Markdown
Collaborator

lgritz commented May 14, 2026

Hi, @luna-y-kim ! The changes in color.h look good to me, but (assuming that you built it and tested it on your side before submitting) I think you got bit in CI by the fact that not all compilers (or versions thereof) actually catch using deprecated functions and issue the error that would stop the build. But others do! So what's happening in the failed tests is that it's finding all the places in our own codebase where we inadvertently failed to check the return results of a function. You'll need to track down those spots and do some appropriate error handling (or, if it really is a case where the result doesn't matter, dispose of it sanely).

@lgritz
Copy link
Copy Markdown
Collaborator

lgritz commented May 14, 2026

It looks like gcc is not catching the errors, but all the CI jobs that use clang do find them. So if you're using gcc on your own machine, that might be why you didn't see any problems when you did a build.

If you're up for addressing this as well, it seems that we're actually disabling this in src/cmake/compiler.cmake, line 188 (-Wno-unused-result). I think eliminating this line would make the discarded result warnings do the right thing for gcc... but I'm not sure what else it might break! There must be some reason why we put it there originally, but I don't remember why, and maybe it's something that isn't even relevant any more.

If you're up for also solving that mystery...

@luna-y-kim
Copy link
Copy Markdown
Contributor Author

Hi, thanks for the explanation. I found all 11 failures are from the same spot ColorConfig::ColorConfig in color_ocio.cpp:810. As a first try, I've added a cast (void) because a constructor can't return the result. However, I see other spots also have the same problem. I'll try to track down those spots and do error handling.

Once I've handled all the discarded-result call sites, I might look at removing -Wno-unused-result from compiler.cmake:188 to see if it's still needed or if it's safe to remove.

@lgritz
Copy link
Copy Markdown
Collaborator

lgritz commented May 15, 2026

Sounds good. I really don't know what will happen when you remove the -Wno-unused-result. Will be interesting to see if there's still a relevant reason why that is there. It appears to have been there for many, many years, and that code has been through enough some movement and refactoring, so I'm not exactly sure when it was first introduced or why.

@lgritz
Copy link
Copy Markdown
Collaborator

lgritz commented May 15, 2026

If you are wondering whether to finish the work tonight, or meet the rest of us at the pub, definitely choose the pub! Fixing the last couple errors in the next couple days is fine.

@lgritz lgritz added devdays26 Dev Days 2026 core APIs Affecting public APIs of core functionality classes, such as ImageInput, ImageOutput, ImageBuf. labels May 15, 2026
@luna-y-kim luna-y-kim force-pushed the nodiscard-color-h branch from 9a3319c to 82cfab7 Compare May 16, 2026 00:41
Signed-off-by: Luna Kim <177369799+luna-y-kim@users.noreply.github.com>
OIIO_NODISCARD_ERROR added to ColorConfig::reset() in color.h requires
updating ColorConfig constructor to use the return value.

Add a cast (void) to explicitly discard the return from reset().
The error still remains queryable via has_error().

Signed-off-by: Luna Kim <177369799+luna-y-kim@users.noreply.github.com>
OIIO_NODISCARD_ERROR added to ColorConfig::reset() in color.h requires
updating set_colorconfig to use the return value.

Replaced the has_error() check with a direct check of bool return from reset().

Signed-off-by: Luna Kim <177369799+luna-y-kim@users.noreply.github.com>
@luna-y-kim luna-y-kim force-pushed the nodiscard-color-h branch from 82cfab7 to 224bb72 Compare May 16, 2026 01:03
@lgritz
Copy link
Copy Markdown
Collaborator

lgritz commented May 16, 2026

The failure for the "VFX2023" test is unrelated to your PR and is being fixed separately. If everything else is ok, we will not hold up the merge just because of that.

@luna-y-kim
Copy link
Copy Markdown
Contributor Author

Sounds good to me. I'll explore the -Wno-unused-result​ in compiler.cmake:188​ separately from this PR so this one can merge.

Copy link
Copy Markdown
Collaborator

@lgritz lgritz 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 the patch, this looks great.

@lgritz lgritz merged commit 1711c39 into AcademySoftwareFoundation:main May 16, 2026
29 of 30 checks passed
@luna-y-kim luna-y-kim deleted the nodiscard-color-h branch May 16, 2026 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core APIs Affecting public APIs of core functionality classes, such as ImageInput, ImageOutput, ImageBuf. devdays26 Dev Days 2026

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants