Skip to content

Commit 1b725f9

Browse files
committed
Fix warnings
1 parent bce072b commit 1b725f9

File tree

6 files changed

+26
-15
lines changed

6 files changed

+26
-15
lines changed

source/c-discord-rich-presence/include/discord_rpc.h

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ struct Activity {
2424
Assets assets;
2525
struct Button {
2626
std::string text = "A button";
27-
std::string link = "https://github.com/riidefi/RiiStudio/tree/master/source/c-discord-rich-presence";
27+
std::string link = "https://github.com/riidefi/RiiStudio/tree/master/"
28+
"source/c-discord-rich-presence";
2829
};
2930
std::vector<Button> buttons{Button{}};
3031
};
@@ -84,29 +85,39 @@ void rsl_rpc_test(struct C_RPC*);
8485

8586
#ifdef __cplusplus
8687
namespace discord_rpc {
88+
89+
static inline char* my_strdup(const char* in) {
90+
auto len = strlen(in);
91+
char* buf = (char*)malloc(len + 1);
92+
memcpy(buf, in, len);
93+
buf[len] = '\0';
94+
return buf;
95+
}
96+
8797
// Functions to create and destroy the Activity_C struct and to access the
8898
// fields of the Activity struct
89-
inline Activity_C* create_activity(const Activity& activity) {
99+
static inline Activity_C* create_activity(const Activity& activity) {
90100
Activity_C* activity_c = new Activity_C;
91101

92102
// Allocate and copy strings for state and details
93-
activity_c->state = strdup(activity.state.c_str());
94-
activity_c->details = strdup(activity.details.c_str());
103+
activity_c->state = my_strdup(activity.state.c_str());
104+
activity_c->details = my_strdup(activity.details.c_str());
95105

96106
// Copy timestamps and assets
97107
activity_c->timestamps.start = activity.timestamps.start;
98108
activity_c->timestamps.end = activity.timestamps.end;
99-
activity_c->assets.large_image = strdup(activity.assets.large_image.c_str());
100-
activity_c->assets.large_text = strdup(activity.assets.large_text.c_str());
109+
activity_c->assets.large_image =
110+
my_strdup(activity.assets.large_image.c_str());
111+
activity_c->assets.large_text = my_strdup(activity.assets.large_text.c_str());
101112

102113
// Allocate and copy button vector
103114
activity_c->buttons.length = activity.buttons.size();
104115
activity_c->buttons.buttons = new Button_C[activity_c->buttons.length];
105116
for (size_t i = 0; i < activity_c->buttons.length; i++) {
106117
activity_c->buttons.buttons[i].text =
107-
strdup(activity.buttons[i].text.c_str());
118+
my_strdup(activity.buttons[i].text.c_str());
108119
activity_c->buttons.buttons[i].link =
109-
strdup(activity.buttons[i].link.c_str());
120+
my_strdup(activity.buttons[i].link.c_str());
110121
}
111122

112123
return activity_c;

source/frontend/legacy_editor/views/PropertyEditor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class PropertyEditor : public StudioWindow, private PropertyEditorWidget {
5252
std::function<kpi::IObject*()> selectionActive,
5353
auto drawImageIcon)
5454
: StudioWindow("Property Editor"), drawImageIcon(drawImageIcon),
55-
mHost(host), mSelectionActive(selectionActive), mRoot(root),
55+
mHost(host), mRoot(root), mSelectionActive(selectionActive),
5656
mSelection(selection) {
5757
setWindowFlag(ImGuiWindowFlags_MenuBar);
5858
setClosable(false);
@@ -141,8 +141,7 @@ template <typename T> void PropertyEditor<T>::draw_() {
141141
ImGui::SameLine();
142142
if (ImGui::Button((const char*)ICON_FA_LINK " Force recompile")) {
143143
for (auto& o : mSelection()) {
144-
if (lib3d::Material* m =
145-
dynamic_cast<lib3d::Material*>(mSelectionActive())) {
144+
if (lib3d::Material* m = dynamic_cast<lib3d::Material*>(o)) {
146145
m->nextGenerationId();
147146
}
148147
}

source/frontend/level_editor/ViewCube.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ bool DrawViewCube(float last_width, float last_height, glm::mat4& view_mtx,
3333

3434
for (int i = 0; i < 4; ++i) {
3535
for (int j = 0; j < 4; ++j) {
36-
auto& f = view_mtx[i][j];
36+
[[maybe_unused]] auto& f = view_mtx[i][j];
3737
assert(!std::isnan(f));
3838
}
3939
}

source/librii/crate/g3d_crate.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ Result<g3d::G3dShader> ReadMDL0Shade(std::span<const u8> file) {
9999
// So the DL parser doesn't discard IndOrders
100100
gx_mat.indirectStages.resize(4);
101101
// Trust the stage count since we have not necessarily read the material yet.
102-
g3d::ReadTev(gx_mat, reader, /* tev_addr */ 0,
103-
/* trust_stagecount */ true, /* brawlbox_bug */ true);
102+
TRY(g3d::ReadTev(gx_mat, reader, /* tev_addr */ 0,
103+
/* trust_stagecount */ true, /* brawlbox_bug */ true));
104104

105105
g3d::G3dShader shader;
106106

source/librii/szs/CTGP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ bool Yaz_open(Yaz_file_struct* file, WRITE_FN fptr) {
570570
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
571571
};
572572

573-
int ret = file->file_write(szsHeader, sizeof(szsHeader), 1);
573+
[[maybe_unused]] int ret = file->file_write(szsHeader, sizeof(szsHeader), 1);
574574
assert(ret == 1);
575575

576576
file->copyLocation = -1;

source/plugins/rhst/RHSTImporter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ void compileAlphaMode(librii::gx::LowLevelGxMaterial& mat,
4949
librii::rhst::AlphaMode alpha_mode) {
5050
librii::hx::PixMode pix_mode = librii::hx::PIX_DEFAULT_OPAQUE;
5151
switch (alpha_mode) {
52+
case librii::rhst::AlphaMode::Custom:
5253
case librii::rhst::AlphaMode::Opaque:
5354
pix_mode = librii::hx::PIX_DEFAULT_OPAQUE;
5455
break;

0 commit comments

Comments
 (0)