From daee2c67de60ba9b9722f429fee8e1dfbd8f42ef Mon Sep 17 00:00:00 2001 From: Gotam Gorabh Date: Thu, 7 Aug 2025 17:59:49 +0530 Subject: [PATCH 1/2] ms-feedback-panel: Prefer char over gchar Signed-off-by: Gotam Gorabh Part-of: --- src/ms-feedback-panel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ms-feedback-panel.c b/src/ms-feedback-panel.c index bc67c4be..a36ab541 100644 --- a/src/ms-feedback-panel.c +++ b/src/ms-feedback-panel.c @@ -785,7 +785,7 @@ ms_feedback_panel_class_init (MsFeedbackPanelClass *klass) gtk_widget_class_bind_template_callback (widget_class, change_notifications_settings); for (int i = 0; i < NOTIFICATION_CATEGORY_LAST; i++) { - g_autofree gchar *widget_name = g_strdup_printf ("%s_notifications_wakeup_switch", + g_autofree char *widget_name = g_strdup_printf ("%s_notifications_wakeup_switch", notification_category_names[i]); gtk_widget_class_bind_template_child_full (widget_class, widget_name, -- GitLab From f568bda502f707100327d14ae00c5cdbf15dc95c Mon Sep 17 00:00:00 2001 From: Gotam Gorabh Date: Wed, 23 Jul 2025 09:55:46 +0530 Subject: [PATCH 2/2] ci: Add check for gchar Prefer char over gchar. Signed-off-by: Gotam Gorabh Part-of: --- .gitlab-ci.yml | 13 +++++++++++++ .gitlab-ci/g-style | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100755 .gitlab-ci/g-style diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 80f20011..3bb30cd1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -39,6 +39,7 @@ variables: FDO_UPSTREAM_REPO: World/Phosh/phosh-mobile-settings DEBIAN_IMAGE: $CI_REGISTRY/world/phosh/phosh-mobile-settings/debian:v0.0.2025-06-16 COMMON_BUILD_OPTS: --werror -Db_coverage=true + GCHECK_DIRS: src tests plugins PHOSH_ADDITIONAL_EXPERIMENTAL_PKGS: libgmobile-dev phoc .trixie_vars: &trixie_vars @@ -134,6 +135,18 @@ format-check: extends: .phosh-format-check allow_failure: true +check-g-style: + stage: style-checks + allow_failure: true + script: + - ./.gitlab-ci/g-style ${GCHECK_DIRS} + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + changes: + paths: + - "**/*.c" + - "**/*.h" + check-meson: stage: style-checks extends: diff --git a/.gitlab-ci/g-style b/.gitlab-ci/g-style new file mode 100755 index 00000000..e752feb9 --- /dev/null +++ b/.gitlab-ci/g-style @@ -0,0 +1,45 @@ +#!/bin/bash + +# Copyright (C) 2025 Tether Operations Limited +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# Author: Gotam Gorabh +# +# Scans specified source directories for 'gchar' usage. +# +# Usage: +# ./g-check src tests plugins +# If no directories are provided, defaults to 'src'. + +set -e + +# Use command-line arguments if given, otherwise default to 'src' +SOURCE_DIRS=("$@") +if [ ${#SOURCE_DIRS[@]} -eq 0 ]; then + SOURCE_DIRS=("src") +fi + +# Use a temporary file for the list of files to check +temp_files=$(mktemp) +trap 'rm -f "$temp_files"' EXIT + +# Collect .c and .h files from the given directories +find "${SOURCE_DIRS[@]}" -type f \( -name "*.c" -o -name "*.h" \) > "$temp_files" + +status=0 + +while read -r file; do + # Check each file for 'gchar' + if grep -nH "\bgchar\b" "$file"; then + echo ":: warning: Avoid using 'gchar' in $file" + status=1 + fi +done < "$temp_files" + +if [ $status -ne 0 ]; then + echo + echo "gchar usage detected. Please use 'char' over 'gchar'." +fi + +exit $status -- GitLab