Skip to content

Commit

Permalink
cleanup: more old style format deprecation (#4247)
Browse files Browse the repository at this point in the history
Remove some long-ago deprecated printf-like error functions. Mark as
deprecated some other ones that we will remove when it gets closer to
3.0 release. I think these are the very last uses internally of the old
style that we want to remove.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
  • Loading branch information
lgritz authored May 3, 2024
1 parent 90f78eb commit acc9605
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 22 deletions.
18 changes: 0 additions & 18 deletions src/include/OpenImageIO/imagebuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1056,15 +1056,6 @@ class OIIO_API ImageBuf {
error(Strutil::fmt::format(fmt, args...));
}

/// Error reporting for ImageBuf: call this with printf-like arguments
/// to report an error. It is not necessary to have the error message
/// contain a trailing newline.
template<typename... Args>
void errorf(const char* fmt, const Args&... args) const
{
error(Strutil::sprintf(fmt, args...));
}

/// Error reporting for ImageBuf: call this with Strutil::format
/// formatting conventions. It is not necessary to have the error
/// message contain a trailing newline. Beware, this is in transition,
Expand All @@ -1076,15 +1067,6 @@ class OIIO_API ImageBuf {
error(Strutil::format(fmt, args...));
}

// Error reporting for ImageBuf: call this with Python / {fmt} /
// std::format style formatting specification.
template<typename... Args>
OIIO_DEPRECATED("use `errorfmt` instead")
void fmterror(const char* fmt, const Args&... args) const
{
error(Strutil::fmt::format(fmt, args...));
}

/// Returns `true` if the ImageBuf has had an error and has an error
/// message ready to retrieve via `geterror()`.
bool has_error(void) const;
Expand Down
2 changes: 2 additions & 0 deletions src/include/OpenImageIO/imageio.h
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,7 @@ class OIIO_API ImageInput {
/// printf-like arguments. It is not necessary to have the error message
/// contain a trailing newline.
template<typename... Args>
OIIO_FORMAT_DEPRECATED
void errorf(const char* fmt, const Args&... args) const {
append_error(Strutil::sprintf (fmt, args...));
}
Expand Down Expand Up @@ -2485,6 +2486,7 @@ class OIIO_API ImageOutput {
/// printf-like arguments. It is not necessary to have the error message
/// contain a trailing newline.
template<typename... Args>
OIIO_FORMAT_DEPRECATED
void errorf(const char* fmt, const Args&... args) const {
append_error(Strutil::sprintf (fmt, args...));
}
Expand Down
2 changes: 1 addition & 1 deletion src/libOpenImageIO/imagebuf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ static void
test_uncaught_error()
{
ImageBuf buf;
buf.error("Boo!");
buf.errorfmt("Boo!");
// buf exists scope and is destroyed without anybody retrieving the error.
}

Expand Down
6 changes: 3 additions & 3 deletions src/libOpenImageIO/imagebufalgo_xform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,7 @@ check_st_warp_args(ImageBuf& dst, const ImageBuf& src, const ImageBuf& stbuf,
{
// Validate ST buffer
if (!stbuf.initialized()) {
dst.error("ImageBufAlgo::st_warp : Uninitialized ST buffer");
dst.errorfmt("ImageBufAlgo::st_warp : Uninitialized ST buffer");
return false;
}

Expand Down Expand Up @@ -1690,7 +1690,7 @@ ImageBufAlgo::st_warp(const ImageBuf& src, const ImageBuf& stbuf,
bool ok = st_warp(result, src, stbuf, filter, chan_s, chan_t, flip_s,
flip_t, roi, nthreads);
if (!ok && !result.has_error()) {
result.error("ImageBufAlgo::st_warp : Unknown error");
result.errorfmt("ImageBufAlgo::st_warp : Unknown error");
}
return result;
}
Expand All @@ -1707,7 +1707,7 @@ ImageBufAlgo::st_warp(const ImageBuf& src, const ImageBuf& stbuf,
bool ok = st_warp(result, src, stbuf, filtername, filterwidth, chan_s,
chan_t, flip_s, flip_t, roi, nthreads);
if (!ok && !result.has_error()) {
result.error("ImageBufAlgo::st_warp : Unknown error");
result.errorfmt("ImageBufAlgo::st_warp : Unknown error");
}
return result;
}
Expand Down

0 comments on commit acc9605

Please sign in to comment.