Skip to content

Commit af99608

Browse files
committed
Fix all calls to terminate_with_message() (format string with%)
1 parent fec85b7 commit af99608

File tree

8 files changed

+18
-18
lines changed

8 files changed

+18
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
### Fixed
2626

2727
- core : fix `CommandBuffer::submitAndAcquireFence()` not setting the internal pointer to null
28+
- Fix all calls to `terminate_with_message()` (format string with `%`) (https://github.com/Simple-Robotics/candlewick/pull/62)
2829

2930
## [0.0.7] - 2025-05-17
3031

src/candlewick/core/DepthAndShadowPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ DepthPass::DepthPass(const Device &device, const MeshLayout &layout,
3737
};
3838
pipeline = SDL_CreateGPUGraphicsPipeline(device, &pipeline_desc);
3939
if (!pipeline)
40-
terminate_with_message("Failed to create graphics pipeline: %s.",
40+
terminate_with_message("Failed to create graphics pipeline: {:s}.",
4141
SDL_GetError());
4242
}
4343

src/candlewick/multibody/RobotScene.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ void RobotScene::initCompositePipeline(const MeshLayout &layout) {
226226

227227
pipelines.wboitComposite = SDL_CreateGPUGraphicsPipeline(device(), &desc);
228228
if (!pipelines.wboitComposite) {
229-
terminate_with_message("Failed to create WBOIT pipeline: %s",
229+
terminate_with_message("Failed to create WBOIT pipeline: {:s}",
230230
SDL_GetError());
231231
}
232232
}

src/candlewick/multibody/RobotScene.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ template <typename T>
2727
[[noreturn]] void
2828
invalid_enum(const char *msg, T type,
2929
std::source_location location = std::source_location::current()) {
30-
terminate_with_message(location, "Invalid enum: %s - %s", msg,
30+
terminate_with_message(location, "Invalid enum: {:s} - {:s}", msg,
3131
magic_enum::enum_name(type));
3232
}
3333

src/candlewick/utils/LoadMaterial.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ PbrMaterial loadFromAssimpMaterial(aiMaterial *material) {
9090
if (retc == material_load_retc::OK)
9191
return pbrFromPhong(phong);
9292

93-
std::string msg = "Failed to load material: return code ";
94-
msg += magic_enum::enum_name(retc);
95-
terminate_with_message(msg);
93+
terminate_with_message("Failed to load material: {:s}",
94+
magic_enum::enum_name(retc));
9695
}
9796
} // namespace candlewick

src/candlewick/utils/MeshData.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class MeshData : public MeshDataBase<MeshData> {
109109
return this->getAttribute<T>(*attr);
110110
}
111111
terminate_with_message(
112-
std::format("Vertex attribute %d not found.", Uint16(loc)));
112+
std::format("Vertex attribute {:d} not found.", Uint16(loc)));
113113
}
114114

115115
template <typename T>
@@ -118,7 +118,7 @@ class MeshData : public MeshDataBase<MeshData> {
118118
return this->getAttribute<T>(*attr);
119119
}
120120
terminate_with_message(
121-
std::format("Vertex attribute %d not found.", Uint16(loc)));
121+
std::format("Vertex attribute {:d} not found.", Uint16(loc)));
122122
}
123123

124124
std::span<const char> vertexData() const { return m_vertexData; }

src/candlewick/utils/VideoRecorder.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,25 +144,25 @@ namespace media {
144144
ret = avcodec_parameters_from_context(videoStream->codecpar, codecContext);
145145
if (ret < 0) {
146146
av_strerror(ret, errbuf, AV_ERROR_MAX_STRING_SIZE);
147-
terminate_with_message("Couldn't copy codec params: %s", errbuf);
147+
terminate_with_message("Couldn't copy codec params: {:s}", errbuf);
148148
}
149149

150150
ret = avcodec_open2(codecContext, codec, nullptr);
151151
if (ret < 0) {
152152
av_strerror(ret, errbuf, AV_ERROR_MAX_STRING_SIZE);
153-
terminate_with_message("Couldn't open codec: %s", errbuf);
153+
terminate_with_message("Couldn't open codec: {:s}", errbuf);
154154
}
155155

156156
ret = avio_open(&formatContext->pb, filename.data(), AVIO_FLAG_WRITE);
157157
if (ret < 0) {
158158
av_strerror(ret, errbuf, AV_ERROR_MAX_STRING_SIZE);
159-
terminate_with_message("Couldn't open output stream: %s", errbuf);
159+
terminate_with_message("Couldn't open output stream: {:s}", errbuf);
160160
}
161161

162162
ret = avformat_write_header(formatContext, nullptr);
163163
if (ret < 0) {
164164
av_strerror(ret, errbuf, AV_ERROR_MAX_STRING_SIZE);
165-
terminate_with_message("Couldn't write output header: %s", errbuf);
165+
terminate_with_message("Couldn't write output header: {:s}", errbuf);
166166
}
167167

168168
packet = av_packet_alloc();
@@ -188,7 +188,7 @@ namespace media {
188188
ret = av_frame_make_writable(tmpFrame);
189189
if (ret < 0)
190190
terminate_with_message(
191-
"Failed to make tmpFrame writable: %s",
191+
"Failed to make tmpFrame writable: {:s}",
192192
av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE, ret));
193193

194194
// copy input payload to tmp frame
@@ -198,7 +198,7 @@ namespace media {
198198
ret = av_frame_make_writable(frame);
199199
if (ret < 0) {
200200
terminate_with_message(
201-
"Failed to make frame writable: %s",
201+
"Failed to make frame writable: {:s}",
202202
av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE, ret));
203203
}
204204
frame->pts = m_frameCounter++;
@@ -209,7 +209,7 @@ namespace media {
209209
ret = avcodec_send_frame(codecContext, frame);
210210
if (ret < 0) {
211211
terminate_with_message(
212-
"Error sending frame %s",
212+
"Error sending frame {:s}",
213213
av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE, ret));
214214
}
215215

@@ -220,7 +220,7 @@ namespace media {
220220
}
221221
if (ret < 0) {
222222
terminate_with_message(
223-
"Error receiving packet from encoder: %s",
223+
"Error receiving packet from encoder: {:s}",
224224
av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE, ret));
225225
}
226226

@@ -274,7 +274,7 @@ namespace media {
274274
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM:
275275
return AV_PIX_FMT_RGBA;
276276
default:
277-
terminate_with_message("Unsupported SDL GPU texture format %s",
277+
terminate_with_message("Unsupported SDL GPU texture format {:s}",
278278
magic_enum::enum_name(pixelFormat));
279279
}
280280
}

src/candlewick/utils/WriteTextureToImage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void saveTextureToFile(CommandBuffer &command_buffer, const Device &device,
112112

113113
if (!ret)
114114
terminate_with_message(
115-
"stbi_write_png() failed. Please check filename (%s)", filename);
115+
"stbi_write_png() failed. Please check filename ({:s})", filename);
116116

117117
if (rgba_pixels)
118118
std::free(rgba_pixels);

0 commit comments

Comments
 (0)