Skip to content

Commit

Permalink
misc: fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
markand committed Oct 22, 2021
1 parent fc5e5fa commit a658eb0
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 59 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Expand Up @@ -28,6 +28,10 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

if (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic -D_POSIX_C_SOURCE=200809L ${CMAKE_C_FLAGS}")

if (CMAKE_C_COMPILER_ID MATCHES "GNU")
set(CMAKE_C_FLAGS "-Wno-format-truncation ${CMAKE_C_FLAGS}")
endif ()
elseif (CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "/wd4090 /wd5105 /wd6031 /wd6001 /wd26451 ${CMAKE_C_FLAGS}")
endif ()
Expand Down
5 changes: 4 additions & 1 deletion doc/mkdocs.yml
Expand Up @@ -42,7 +42,7 @@ nav:
- FAQ: dev/faq.md
- Howto:
- dev/howto/01-init.md
- API Reference:
- C API Reference:
- libmlk-core:
- action: dev/api/core/action.md
- alloc: dev/api/core/alloc.md
Expand Down Expand Up @@ -75,3 +75,6 @@ nav:
- util: dev/api/core/util.md
- window: dev/api/core/window.md
- zfile: dev/api/core/zfile.md
- Javascript API Reference:
- Core:
- animation: dev/jsapi/core/animation.md
30 changes: 15 additions & 15 deletions extern/libduktape/duktape.h
Expand Up @@ -18,21 +18,21 @@
* ===============
* Duktape license
* ===============
*
*
* (http://opensource.org/licenses/MIT)
*
*
* Copyright (c) 2013-2019 by Duktape authors (see AUTHORS.rst)
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -47,24 +47,24 @@
* ===============
* Duktape authors
* ===============
*
*
* Copyright
* =========
*
*
* Duktape copyrights are held by its authors. Each author has a copyright
* to their contribution, and agrees to irrevocably license the contribution
* under the Duktape ``LICENSE.txt``.
*
*
* Authors
* =======
*
*
* Please include an e-mail address, a link to your GitHub profile, or something
* similar to allow your contribution to be identified accurately.
*
*
* The following people have contributed code, website contents, or Wiki contents,
* and agreed to irrevocably license their contributions under the Duktape
* ``LICENSE.txt`` (in order of appearance):
*
*
* * Sami Vaarala <sami.vaarala@iki.fi>
* * Niki Dobrev
* * Andreas \u00d6man <andreas@lonelycoder.com>
Expand Down Expand Up @@ -110,13 +110,13 @@
* * Luis de Bethencourt (https://github.com/luisbg)
* * Ian Whyman (https://github.com/v00d00)
* * Rick Sayre (https://github.com/whorfin)
*
*
* Other contributions
* ===================
*
*
* The following people have contributed something other than code (e.g. reported
* bugs, provided ideas, etc; roughly in order of appearance):
*
*
* * Greg Burns
* * Anthony Rabine
* * Carlos Costa
Expand Down Expand Up @@ -152,7 +152,7 @@
* * Andrew Janke (https://github.com/apjanke)
* * Unamer (https://github.com/unamer)
* * Karl Dahlke (eklhad@gmail.com)
*
*
* If you are accidentally missing from this list, send me an e-mail
* (``sami.vaarala@iki.fi``) and I'll fix the omission.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/libmlk-core-js/core/js-animation.c
Expand Up @@ -38,7 +38,7 @@ self(duk_context *ctx)
duk_pop_2(ctx);

if (!anim)
duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a Animation object");
return (void)duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a Animation object"), NULL;

return anim;
}
Expand Down
4 changes: 2 additions & 2 deletions src/libmlk-core-js/core/js-clock.c
Expand Up @@ -25,7 +25,7 @@

#define SIGNATURE DUK_HIDDEN_SYMBOL("Mlk.Clock")

static struct clock *
static inline struct clock *
self(duk_context *ctx)
{
struct clock *clk;
Expand All @@ -36,7 +36,7 @@ self(duk_context *ctx)
duk_pop_2(ctx);

if (!clk)
duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a Clock object");
return (void)duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a Clock object"), NULL;

return clk;
}
Expand Down
13 changes: 7 additions & 6 deletions src/libmlk-core-js/core/js-font.c
Expand Up @@ -41,7 +41,7 @@ self(duk_context *ctx)
duk_pop_2(ctx);

if (!font)
duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a Font object");
return (void)duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a Font object"), NULL;

return font;
}
Expand All @@ -60,7 +60,7 @@ Font_setStyle(duk_context *ctx)
const int style = duk_require_int(ctx, 0);

if (style < 0 || style >= FONT_STYLE_LAST)
duk_error(ctx, DUK_ERR_ERROR, "invalid style");
return duk_error(ctx, DUK_ERR_ERROR, "invalid style");

self(ctx)->style = style;

Expand All @@ -84,14 +84,15 @@ Font_new(duk_context *ctx)
struct font *font;

if (vfs_open(js_core_global_vfs(ctx), &file, entry, "r") < 0)
duk_error(ctx, DUK_ERR_ERROR, "%s", error());
return duk_error(ctx, DUK_ERR_ERROR, "%s", error());

font = alloc_new0(sizeof (*font));

if (font_openvfs(font, &file, size) < 0) {
free(font);
vfs_file_finish(&file);
duk_error(ctx, DUK_ERR_ERROR, "%s", error());

return duk_error(ctx, DUK_ERR_ERROR, "%s", error());
}

vfs_file_finish(&file);
Expand Down Expand Up @@ -122,7 +123,7 @@ Font_render(duk_context *ctx)

if (font_render(self(ctx), tex, text, color) < 0) {
free(tex);
duk_error(ctx, DUK_ERR_ERROR, "%s", error());
return duk_error(ctx, DUK_ERR_ERROR, "%s", error());
}

js_texture_push(ctx, tex);
Expand All @@ -137,7 +138,7 @@ Font_query(duk_context *ctx)
unsigned int w, h;

if (font_query(self(ctx), text, &w, &h) < 0)
duk_error(ctx, DUK_ERR_ERROR, "%s", error());
return duk_error(ctx, DUK_ERR_ERROR, "%s", error());

duk_push_object(ctx);
duk_push_uint(ctx, w);
Expand Down
4 changes: 3 additions & 1 deletion src/libmlk-core-js/core/js-game.c
Expand Up @@ -35,7 +35,7 @@ Game_push(duk_context *ctx)

if (game.state == &game.states[GAME_STATE_MAX]) {
state_finish(state);
duk_error(ctx, DUK_ERR_RANGE_ERROR, "too many states");
return duk_error(ctx, DUK_ERR_RANGE_ERROR, "too many states");
}

game_push(state);
Expand All @@ -46,6 +46,8 @@ Game_push(duk_context *ctx)
static duk_ret_t
Game_pop(duk_context *ctx)
{
(void)ctx;

if (game.state == &game.states[0])
return 0;

Expand Down
9 changes: 5 additions & 4 deletions src/libmlk-core-js/core/js-music.c
Expand Up @@ -39,7 +39,7 @@ self(duk_context *ctx)
duk_pop_2(ctx);

if (!mus)
duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a Music object");
return (void)duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a Music object"), NULL;

return mus;
}
Expand All @@ -52,14 +52,15 @@ Music_new(duk_context *ctx)
struct music *mus;

if (vfs_open(js_core_global_vfs(ctx), &file, entry, "r") < 0)
duk_error(ctx, DUK_ERR_ERROR, "%s", error());
return duk_error(ctx, DUK_ERR_ERROR, "%s", error());

mus = alloc_new0(sizeof (*mus));

if (music_openvfs(mus, &file) < 0) {
free(mus);
vfs_file_finish(&file);
duk_error(ctx, DUK_ERR_ERROR, "%s", error());

return duk_error(ctx, DUK_ERR_ERROR, "%s", error());
}

vfs_file_finish(&file);
Expand All @@ -79,7 +80,7 @@ Music_play(duk_context *ctx)
const unsigned int fadein = duk_get_uint_default(ctx, 0, 0);

if (music_play(self(ctx), flags, fadein) < 0)
duk_error(ctx, DUK_ERR_ERROR, "%s", error());
return duk_error(ctx, DUK_ERR_ERROR, "%s", error());

return 0;
}
Expand Down
15 changes: 8 additions & 7 deletions src/libmlk-core-js/core/js-sound.c
Expand Up @@ -39,7 +39,7 @@ self(duk_context *ctx)
duk_pop_2(ctx);

if (!snd)
duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a Sound object");
return (void)duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a Sound object"), NULL;

return snd;
}
Expand All @@ -52,14 +52,15 @@ Sound_constructor(duk_context *ctx)
struct sound *snd;

if (vfs_open(js_core_global_vfs(ctx), &file, entry, "r") < 0)
duk_error(ctx, DUK_ERR_ERROR, "%s", error());
return duk_error(ctx, DUK_ERR_ERROR, "%s", error());

snd = alloc_new0(sizeof (*snd));

if (sound_openvfs(snd, &file) < 0) {
free(snd);
vfs_file_finish(&file);
duk_error(ctx, DUK_ERR_ERROR, "%s", error());

return duk_error(ctx, DUK_ERR_ERROR, "%s", error());
}

vfs_file_finish(&file);
Expand All @@ -70,8 +71,8 @@ Sound_constructor(duk_context *ctx)
duk_pop(ctx);

return 0;


}

static duk_ret_t
Expand All @@ -97,8 +98,8 @@ Sound_proto_play(duk_context *ctx)
const unsigned int fadein = duk_get_uint_default(ctx, 1, 0);

if (sound_play(self(ctx), channel, fadein) < 0)
duk_error(ctx, DUK_ERR_ERROR, "%s", error());
return duk_error(ctx, DUK_ERR_ERROR, "%s", error());

return 0;
}

Expand Down
12 changes: 6 additions & 6 deletions src/libmlk-core-js/core/js-sprite.c
Expand Up @@ -39,7 +39,7 @@ self(duk_context *ctx)
duk_pop_2(ctx);

if (!sprite)
duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a Sprite object");
return (void)duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a Sprite object"), NULL;

return sprite;
}
Expand Down Expand Up @@ -92,9 +92,9 @@ Sprite_draw(duk_context *ctx)
const int y = duk_require_int(ctx, 3);

if (r >= sprite->nrows)
duk_error(ctx, DUK_ERR_RANGE_ERROR, "row overflow: %u >= %u", r, sprite->nrows);
return duk_error(ctx, DUK_ERR_RANGE_ERROR, "row overflow: %u >= %u", r, sprite->nrows);
if (c >= sprite->ncols)
duk_error(ctx, DUK_ERR_RANGE_ERROR, "column overflow: %u >= %u", c, sprite->ncols);
return duk_error(ctx, DUK_ERR_RANGE_ERROR, "column overflow: %u >= %u", c, sprite->ncols);

sprite_draw(sprite, r, c, x, y);

Expand All @@ -113,9 +113,9 @@ Sprite_scale(duk_context *ctx)
const unsigned int h = duk_require_uint(ctx, 5);

if (r >= sprite->nrows)
duk_error(ctx, DUK_ERR_RANGE_ERROR, "row overflow: %u >= %u", r, sprite->nrows);
return duk_error(ctx, DUK_ERR_RANGE_ERROR, "row overflow: %u >= %u", r, sprite->nrows);
if (c >= sprite->ncols)
duk_error(ctx, DUK_ERR_RANGE_ERROR, "column overflow: %u >= %u", c, sprite->ncols);
return duk_error(ctx, DUK_ERR_RANGE_ERROR, "column overflow: %u >= %u", c, sprite->ncols);

sprite_scale(sprite, r, c, x, y, w, h);

Expand Down Expand Up @@ -154,7 +154,7 @@ js_sprite_require(duk_context *ctx, duk_idx_t idx)
duk_pop(ctx);

if (!sprite)
duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a Sprite object");
return (void)duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a Sprite object"), NULL;

return sprite;
}
6 changes: 3 additions & 3 deletions src/libmlk-core-js/core/js-state.c
Expand Up @@ -159,7 +159,7 @@ self(duk_context *ctx)
duk_pop_2(ctx);

if (!data)
duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a State object");
return (void)duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a State object"), NULL;

return data;
}
Expand Down Expand Up @@ -231,9 +231,9 @@ js_state_require(duk_context *ctx, duk_idx_t idx)
self = duk_to_pointer(ctx, -1);
duk_pop(ctx);
}

if (!self)
duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a State object");
return (void)duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a State object"), NULL;

self->refc++;

Expand Down

0 comments on commit a658eb0

Please sign in to comment.