Skip to content

fix(native): Fix build-time warnings with C++ builds#1671

Merged
mujacica merged 2 commits intomasterfrom
fix/native-warnings
Apr 30, 2026
Merged

fix(native): Fix build-time warnings with C++ builds#1671
mujacica merged 2 commits intomasterfrom
fix/native-warnings

Conversation

@mujacica
Copy link
Copy Markdown
Contributor

@mujacica mujacica commented Apr 25, 2026

  • Fix build-time warnings with C++ builds

Summed size of utsname fields could be larger than the 256 bytes we allow for the csd_version string. (see linux/sysname.h`). Thus we increase the size to fit these fields.

_deps/sentry-build/CMakeFiles/sentry.dir/src/transports/sentry_http_transport.c.o
/home/runner/work/teapot/teapot/build/debug/_deps/sentry-src/src/transports/sentry_http_transport.c: In function ‘retry_send_cb’:
/home/runner/work/teapot/teapot/build/debug/_deps/sentry-src/src/transports/sentry_http_transport.c:258:37: warning: missing braces around initializer [-Wmissing-braces]
258 | sentry_client_report_t report = { { 0 } };
| ^
| { }
/home/runner/work/teapot/teapot/build/debug/_deps/sentry-src/src/transports/sentry_http_transport.c: In function ‘http_send_task’:
/home/runner/work/teapot/teapot/build/debug/_deps/sentry-src/src/transports/sentry_http_transport.c:305:37: warning: missing braces around initializer [-Wmissing-braces]
305 | sentry_client_report_t report = { { 0 } };
| ^
| { }

/home/runner/work/teapot/teapot/build/debug/_deps/sentry-src/src/backends/native/minidump/sentry_minidump_linux.c: In function ‘write_system_info_stream’:
/home/runner/work/teapot/teapot/build/debug/_deps/sentry-src/src/backends/native/minidump/sentry_minidump_linux.c:526:62: warning: ‘%s’ directive output may be truncated writing up to 64 bytes into a region of size between 61 and 253 [-Wformat-truncation=]
526 | snprintf(csd_version, sizeof(csd_version), "%s %s %s %s", uts.sysname,
| ^~
527 | uts.release, uts.version, uts.machine);
| ~~~~~~~~~~~
/home/runner/work/teapot/teapot/build/debug/_deps/sentry-src/src/backends/native/minidump/sentry_minidump_linux.c:526:9: note: ‘snprintf’ output between 4 and 260 bytes into a destination of size 256
526 | snprintf(csd_version, sizeof(csd_version), "%s %s %s %s", uts.sysname,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
527 | uts.release, uts.version, uts.machine);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@mujacica mujacica force-pushed the fix/native-warnings branch from 86cfe24 to a74499e Compare April 27, 2026 08:19
@mujacica mujacica marked this pull request as ready for review April 27, 2026 08:22
@mujacica mujacica requested a review from jpnurmi April 27, 2026 08:22
// Populate OS version from uname(), matching Crashpad behavior
struct utsname uts;
char csd_version[256] = "";
char csd_version[512] = "";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we need the full 512 or is this a bit overkill (since we know it to be upper-bounded by 260, maybe we just take the next largest size divisible by 8)

Suggested change
char csd_version[512] = "";
char csd_version[264] = "";

@mujacica mujacica force-pushed the fix/native-warnings branch from a74499e to 3be9ced Compare April 30, 2026 07:48
@mujacica mujacica merged commit f701f6f into master Apr 30, 2026
60 checks passed
@mujacica mujacica deleted the fix/native-warnings branch April 30, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants