Skip to content

Commit 7520202

Browse files
committed
Avoid GCC compiler warnings
1 parent b02b6dd commit 7520202

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

src/main-window.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,11 @@ void Main_Window::update_tileset_metadata() {
711711
}
712712
else {
713713
char buffer[FL_PATH_MAX] = {};
714-
sprintf(buffer, "%d files", _tilesets.size());
714+
#ifdef __GNUC__
715+
sprintf(buffer, "%zu files", _tilesets.size());
716+
#else
717+
sprintf(buffer, "%u files", _tilesets.size());
718+
#endif
715719
_tileset_name->copy_label(buffer);
716720
}
717721
}

src/preferences.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ void Preferences::set(const char *key, int value) {
2020
std::string Preferences::get_string(const char *key) {
2121
char *value;
2222
global_prefs.get(key, value, "");
23-
if (!value) { value = ""; }
24-
std::string s(value);
23+
std::string s(value ? value : "");
2524
delete value;
2625
return s;
2726
}
2827

29-
void Preferences::set_string(const char *key, std::string &value) {
28+
void Preferences::set_string(const char *key, std::string &value) {
3029
global_prefs.set(key, value.c_str());
3130
}

src/tile-buttons.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ void Tile_State::draw(int x, int y, bool active, bool selected) {
106106
}
107107
}
108108
if (!gfx) {
109-
char hi = (char)((id & 0xF0) >> 4), lo = (char)(id & 0x0F);
110-
const char buffer[3] = {hi > 9 ? 'A' + hi - 10 : '0' + hi, lo > 9 ? 'A' + lo - 10 : '0' + lo, '\0'};
109+
uint8_t hi = (id & 0xF0) >> 4, lo = id & 0x0F;
110+
char l1 = (char)(hi > 9 ? 'A' + hi - 10 : '0' + hi), l2 = (char)(lo > 9 ? 'A' + lo - 10 : '0' + lo);
111+
const char buffer[3] = {l1, l2, '\0'};
111112
bool r = Config::rainbow_tiles();
112113
Fl_Color bg = bg_colors[r ? lo : 0];
113114
if (!active) { bg = fl_inactive(bg); }
@@ -120,7 +121,7 @@ void Tile_State::draw(int x, int y, bool active, bool selected) {
120121
}
121122
if (Config::attributes() && color > -1) {
122123
sgb_color_images[color].draw(x, y, TILE_SIZE_2X, TILE_SIZE_2X);
123-
const char buffer[2] = {'0' + (char)color, '\0'};
124+
const char buffer[2] = {(char)('0' + color), '\0'};
124125
fl_font(FL_COURIER_BOLD, s);
125126
draw_outlined_text(buffer, x, y, TILE_SIZE_2X, TILE_SIZE_2X, FL_ALIGN_CENTER, sgb_colors[color]);
126127
}

src/tile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ bool is_blank_tile(Tile &tile);
1919
bool are_identical_tiles(Tile &t1, Tile &t2, Tilemap_Format fmt, bool &x_flip, bool &y_flip);
2020
Tile *get_image_tiles(Fl_RGB_Image *img, size_t &n);
2121

22-
#endif TILE_H
22+
#endif

0 commit comments

Comments
 (0)