Skip to content

Commit

Permalink
Merge pull request #207 from wdhongtw/more-check
Browse files Browse the repository at this point in the history
Upgrade to C23 and adding more static check from compiler
  • Loading branch information
kanru authored Jul 6, 2024
2 parents 2ffbf00 + 9485582 commit bbbb36c
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 91 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:

- name: Build
run: |
cmake --preset default
cmake --build --preset default --verbose
cmake --build --preset default -t install --verbose
cmake --preset c23-release-ci
cmake --build --preset c23-release-ci --verbose
cmake --build --preset c23-release-ci -t install --verbose
- name: Test
env:
Expand All @@ -33,7 +33,7 @@ jobs:
run: |
glib-compile-schemas src/setup --targetdir=build/bin
weston --no-config --socket=wl-headless --backend=headless &
WAYLAND_DISPLAY=wl-headless cmake --build --preset default -t test --verbose
WAYLAND_DISPLAY=wl-headless cmake --build --preset c23-release-ci -t test --verbose
coverage:
runs-on: ubuntu-latest
Expand All @@ -60,8 +60,8 @@ jobs:
- name: Build
run: |
cmake --preset c99-coverage
cmake --build --preset c99-coverage --verbose
cmake --preset c23-coverage
cmake --build --preset c23-coverage --verbose
- name: Test
env:
Expand All @@ -71,7 +71,7 @@ jobs:
source "$HOME/.cargo/env"
glib-compile-schemas src/setup --targetdir=build/bin
weston --no-config --socket=wl-headless --backend=headless &
WAYLAND_DISPLAY=wl-headless cmake --build --preset c99-coverage -t test --verbose
WAYLAND_DISPLAY=wl-headless cmake --build --preset c23-coverage -t test --verbose
./grcov . -s . -b . --keep-only 'src/*' --llvm -t lcov -o coverage.lcov
- name: Upload coverage reports to Codecov
Expand Down
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ set(DESCRIPTION_TRANSLATIONS
本輸入法也同時支援帶調漢語拼音輸入。")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
option(ERROR_ON_WARNING "Toggle error-on-warning build" OFF)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
if(ERROR_ON_WARNING)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif()

set(AUTHORS "Peng Huang, Ding-Yi Chen")
set(MAINTAINER "Ding-Yi Chen <dchen at redhat.com>")
Expand Down Expand Up @@ -77,7 +81,7 @@ pkg_check_modules(LIBADWAITA REQUIRED IMPORTED_TARGET libadwaita-1)
find_program(GLIB_COMPILE_RESOURCES NAMES glib-compile-resources REQUIRED)
find_program(GLIB_COMPILE_SCHEMAS NAMES glib-compile-schemas)

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD 23)
add_compile_definitions(_XOPEN_SOURCE)

# Directory that store ibus-chewing icons
Expand Down
37 changes: 26 additions & 11 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"displayName": "Default (Release)",
"description": "Default preset for release build",
"inherits": [
"c99-release"
"c23-release"
]
},
{
Expand All @@ -29,31 +29,42 @@
}
},
{
"name": "c99",
"displayName": "C99 (Debug)",
"name": "c23",
"displayName": "C23 (Debug)",
"description": "Build with only C dependencies",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "c99-release",
"displayName": "C99 (Release)",
"name": "c23-release",
"displayName": "C23 (Release)",
"description": "Build with only C dependencies",
"inherits": [
"c99"
"c23"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "c99-coverage",
"displayName": "C99 (Debug Coverage)",
"name": "c23-release-ci",
"displayName": "C23 (Release CI)",
"description": "Build with only C dependencies",
"inherits": [
"c99",
"c23-release"
],
"cacheVariables": {
"ERROR_ON_WARNING": true
}
},
{
"name": "c23-coverage",
"displayName": "C23 (Debug Coverage)",
"description": "Build with only C dependencies",
"inherits": [
"c23",
"coverage-base"
]
}
Expand All @@ -64,8 +75,12 @@
"configurePreset": "default"
},
{
"name": "c99-coverage",
"configurePreset": "c99-coverage"
"name": "c23-coverage",
"configurePreset": "c23-coverage"
},
{
"name": "c23-release-ci",
"configurePreset": "c23-release-ci"
}
]
}
23 changes: 11 additions & 12 deletions src/GSettingsBackend.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,25 @@ GValue *mkdg_g_settings_read_value(GSettings *settings, GValue *value,
/*============================================
* Interface routines
*/
gchar *mkdg_g_settings_backend_get_key(MkdgBackend *backend,
const gchar *section, const gchar *key,
gpointer userData) {
gchar *mkdg_g_settings_backend_get_key([[maybe_unused]] MkdgBackend *backend,
[[maybe_unused]] const gchar *section,
const gchar *key,
[[maybe_unused]] gpointer userData) {
return (gchar *)key;
}

GValue *mkdg_g_settings_backend_read_value(MkdgBackend *backend, GValue *value,
const gchar *section,
const gchar *key,
gpointer userData) {
GValue *mkdg_g_settings_backend_read_value(
MkdgBackend *backend, GValue *value, [[maybe_unused]] const gchar *section,
const gchar *key, [[maybe_unused]] gpointer userData) {
GSettings *config = (GSettings *)backend->config;

return mkdg_g_settings_read_value(config, value, key);
}

gboolean mkdg_g_settings_backend_write_value(MkdgBackend *backend,
GValue *value,
const gchar *section,
const gchar *key,
gpointer userData) {
gboolean
mkdg_g_settings_backend_write_value(MkdgBackend *backend, GValue *value,
const gchar *section, const gchar *key,
[[maybe_unused]] gpointer userData) {
GSettings *config = (GSettings *)backend->config;
GVariant *confValue = g_variant_ref_sink(mkdg_g_value_to_g_variant(value));

Expand Down
44 changes: 17 additions & 27 deletions src/IBusChewingApplier.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static ChewingKbType kbType_id_get_index(const gchar *kbType_id) {
/*============================================
* Callback routines
*/
gboolean KBType_apply_callback(PropertyContext *ctx, gpointer userData) {
gboolean KBType_apply_callback(PropertyContext *ctx, gpointer) {
GValue *value = &(ctx->value);

IBUS_CHEWING_LOG(DEBUG, "KBType_apply_callback(%s,%s)", ctx->spec->key,
Expand All @@ -28,7 +28,7 @@ gboolean KBType_apply_callback(PropertyContext *ctx, gpointer userData) {
return TRUE;
}

gboolean selKeys_apply_callback(PropertyContext *ctx, gpointer userData) {
gboolean selKeys_apply_callback(PropertyContext *ctx, gpointer) {
GValue *value = &(ctx->value);

IBUS_CHEWING_LOG(DEBUG, "selKeys_apply_callback(%s,%s)", ctx->spec->key,
Expand All @@ -40,7 +40,7 @@ gboolean selKeys_apply_callback(PropertyContext *ctx, gpointer userData) {
return TRUE;
}

gboolean autoShiftCur_apply_callback(PropertyContext *ctx, gpointer userData) {
gboolean autoShiftCur_apply_callback(PropertyContext *ctx, gpointer) {
GValue *value = &(ctx->value);
IBusChewingPreEdit *icPreEdit = (IBusChewingPreEdit *)ctx->parent;

Expand All @@ -49,8 +49,7 @@ gboolean autoShiftCur_apply_callback(PropertyContext *ctx, gpointer userData) {
return TRUE;
}

gboolean addPhraseDirection_apply_callback(PropertyContext *ctx,
gpointer userData) {
gboolean addPhraseDirection_apply_callback(PropertyContext *ctx, gpointer) {
GValue *value = &(ctx->value);
IBusChewingPreEdit *icPreEdit = (IBusChewingPreEdit *)ctx->parent;

Expand All @@ -59,13 +58,11 @@ gboolean addPhraseDirection_apply_callback(PropertyContext *ctx,
return TRUE;
}

gboolean cleanBufferFocusOut_apply_callback(PropertyContext *ctx,
gpointer userData) {
gboolean cleanBufferFocusOut_apply_callback(PropertyContext *, gpointer) {
return TRUE;
}

gboolean easySymbolInput_apply_callback(PropertyContext *ctx,
gpointer userData) {
gboolean easySymbolInput_apply_callback(PropertyContext *ctx, gpointer) {
GValue *value = &(ctx->value);
IBusChewingPreEdit *icPreEdit = (IBusChewingPreEdit *)ctx->parent;

Expand All @@ -75,8 +72,7 @@ gboolean easySymbolInput_apply_callback(PropertyContext *ctx,
return TRUE;
}

gboolean escCleanAllBuf_apply_callback(PropertyContext *ctx,
gpointer userData) {
gboolean escCleanAllBuf_apply_callback(PropertyContext *ctx, gpointer) {
GValue *value = &(ctx->value);
IBusChewingPreEdit *icPreEdit = (IBusChewingPreEdit *)ctx->parent;

Expand All @@ -86,8 +82,7 @@ gboolean escCleanAllBuf_apply_callback(PropertyContext *ctx,
}

/* Additional symbol buffer length */
gboolean maxChiSymbolLen_apply_callback(PropertyContext *ctx,
gpointer userData) {
gboolean maxChiSymbolLen_apply_callback(PropertyContext *ctx, gpointer) {
GValue *value = &(ctx->value);
IBusChewingPreEdit *icPreEdit = (IBusChewingPreEdit *)ctx->parent;

Expand All @@ -97,13 +92,12 @@ gboolean maxChiSymbolLen_apply_callback(PropertyContext *ctx,
return TRUE;
}

gboolean defaultEnglishLetterCase_apply_callback(PropertyContext *ctx,
gpointer userData) {
gboolean defaultEnglishLetterCase_apply_callback(PropertyContext *, gpointer) {
/* Use MkdgProperty directly, no need to call IBusChewingEngine */
return TRUE;
}

gboolean syncCapsLock_apply_callback(PropertyContext *ctx, gpointer userData) {
gboolean syncCapsLock_apply_callback(PropertyContext *ctx, gpointer) {
GValue *value = &(ctx->value);
IBusChewingPreEdit *icPreEdit = (IBusChewingPreEdit *)ctx->parent;
const gchar *str = g_value_get_string(value);
Expand All @@ -121,22 +115,20 @@ gboolean syncCapsLock_apply_callback(PropertyContext *ctx, gpointer userData) {
return TRUE;
}

gboolean candPerPage_apply_callback(PropertyContext *ctx, gpointer userData) {
gboolean candPerPage_apply_callback(PropertyContext *ctx, gpointer) {
IBusChewingPreEdit *icPreEdit = (IBusChewingPreEdit *)ctx->parent;

ibus_chewing_lookup_table_resize(icPreEdit->iTable, icPreEdit->iProperties,
icPreEdit->context);
return TRUE;
}

gboolean showPageNumber_apply_callback(PropertyContext *ctx,
gpointer userData) {
gboolean showPageNumber_apply_callback(PropertyContext *, gpointer) {
/* Use MkdgProperty directly, no need to call IBusChewingEngine */
return TRUE;
}

gboolean phraseChoiceRearward_apply_callback(PropertyContext *ctx,
gpointer userData) {
gboolean phraseChoiceRearward_apply_callback(PropertyContext *ctx, gpointer) {
GValue *value = &(ctx->value);
IBusChewingPreEdit *icPreEdit = (IBusChewingPreEdit *)ctx->parent;

Expand All @@ -145,8 +137,7 @@ gboolean phraseChoiceRearward_apply_callback(PropertyContext *ctx,
return TRUE;
}

gboolean spaceAsSelection_apply_callback(PropertyContext *ctx,
gpointer userData) {
gboolean spaceAsSelection_apply_callback(PropertyContext *ctx, gpointer) {
GValue *value = &(ctx->value);
IBusChewingPreEdit *icPreEdit = (IBusChewingPreEdit *)ctx->parent;

Expand All @@ -155,18 +146,17 @@ gboolean spaceAsSelection_apply_callback(PropertyContext *ctx,
return TRUE;
}

gboolean plainZhuyin_apply_callback(PropertyContext *ctx, gpointer userData) {
gboolean plainZhuyin_apply_callback(PropertyContext *, gpointer) {
/* Use MkdgProperty directly, no need to call IBusChewingEngine */
return TRUE;
}

gboolean verticalLookupTable_apply_callback(PropertyContext *ctx,
gpointer userData) {
gboolean verticalLookupTable_apply_callback(PropertyContext *, gpointer) {
/* Use MkdgProperty directly, no need to call IBusChewingEngine */
return TRUE;
}

gboolean chiEngToggle_apply_callback(PropertyContext *ctx, gpointer userData) {
gboolean chiEngToggle_apply_callback(PropertyContext *, gpointer) {
/* Use MkdgProperty directly, no need to call IBusChewingEngine */
return TRUE;
}
9 changes: 5 additions & 4 deletions src/IBusChewingLookupTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ void ibus_chewing_lookup_table_resize(IBusLookupTable *iTable,
ibus_lookup_table_set_orientation(iTable, verticalLookupTable);
}

guint ibus_chewing_lookup_table_update(IBusLookupTable *iTable,
IBusChewingProperties *iProperties,
ChewingContext *context) {
guint ibus_chewing_lookup_table_update(
IBusLookupTable *iTable,
[[maybe_unused]] IBusChewingProperties *iProperties,
ChewingContext *context) {
IBusText *iText = NULL;
guint i;
gint i;
gint choicePerPage = chewing_cand_ChoicePerPage(context);
gint totalChoice = chewing_cand_TotalChoice(context);
gint currentPage = chewing_cand_CurrentPage(context);
Expand Down
5 changes: 3 additions & 2 deletions src/IBusChewingPreEdit.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,9 @@ EventResponse self_handle_end(IBusChewingPreEdit *self, KSym kSym,
return event_process_or_ignore(!chewing_handle_End(self->context));
}

EventResponse self_handle_special(IBusChewingPreEdit *self, KSym kSym,
KeyModifiers unmaskedMod) {
EventResponse self_handle_special([[maybe_unused]] IBusChewingPreEdit *self,
[[maybe_unused]] KSym kSym,
[[maybe_unused]] KeyModifiers unmaskedMod) {
/* KSym >=128 is special key, which IM ignore. */
IBUS_CHEWING_LOG(MSG, "ignore special key");
return EVENT_RESPONSE_IGNORE;
Expand Down
Loading

0 comments on commit bbbb36c

Please sign in to comment.