diff options
author | Sergey Sharybin <sergey@blender.org> | 2022-11-07 17:43:20 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey@blender.org> | 2022-11-08 14:01:01 +0300 |
commit | 0d945fe20e87ac7ada2d565f751146c2e8fa1ed6 (patch) | |
tree | b74198f5f7dd5577848e533ad68b9b27c1170ca7 /source/blender/editors/render/render_preview.cc | |
parent | dc609d9f1f6eadc565e75a6d6823d78c21af96a2 (diff) |
Fix deprecation warnings about printf() on macOS
The new Xcode 14.1 brings the new Apple Clang compiler which
considers sprintf unsafe and geenrates deprecation warnings
suggesting to sue snprintf instead. This only happens for C++
code by default, and C code can still use sprintf without any
warning.
This changes does the following:
- Whenever is trivial replace sprintf() with BLI_snprintf.
- For all other cases use the newly introduced BLI_sprintf
which is a wrapper around sprintf() but without warning.
There is a discouragement note in the BLI_sprintf comment to
suggest use of BLI_snprintf when the size is known.
Differential Revision: https://developer.blender.org/D16410
Diffstat (limited to 'source/blender/editors/render/render_preview.cc')
-rw-r--r-- | source/blender/editors/render/render_preview.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/source/blender/editors/render/render_preview.cc b/source/blender/editors/render/render_preview.cc index 5aae48b1138..5bfa038b4f4 100644 --- a/source/blender/editors/render/render_preview.cc +++ b/source/blender/editors/render/render_preview.cc @@ -630,10 +630,10 @@ static bool ed_preview_draw_rect(ScrArea *area, int split, int first, rcti *rect bool ok = false; if (!split || first) { - sprintf(name, "Preview %p", (void *)area); + BLI_snprintf(name, sizeof(name), "Preview %p", (void *)area); } else { - sprintf(name, "SecondPreview %p", (void *)area); + BLI_snprintf(name, sizeof(name), "SecondPreview %p", (void *)area); } if (split) { @@ -1152,10 +1152,10 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs } if (!split || first) { - sprintf(name, "Preview %p", sp->owner); + BLI_snprintf(name, sizeof(name), "Preview %p", sp->owner); } else { - sprintf(name, "SecondPreview %p", sp->owner); + BLI_snprintf(name, sizeof(name), "SecondPreview %p", sp->owner); } re = RE_GetRender(name); |