This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new a5f8018475 GH-40961: [GLib] Suppress warnings for Vala examples on 
macOS (#40962)
a5f8018475 is described below

commit a5f80184750fb09fd232f2acbe5558b03b45a156
Author: Sutou Kouhei <[email protected]>
AuthorDate: Thu Apr 4 06:41:04 2024 +0900

    GH-40961: [GLib] Suppress warnings for Vala examples on macOS (#40962)
    
    ### Rationale for this change
    
    There are some warnings for Vala examples on macOS:
    
    ```text
    FAILED: example/vala/read-file.p/meson-generated_read-file.c.o
    ccache cc -Iexample/vala/read-file.p -Iexample/vala 
-I../../c_glib/example/vala -I/Users/runner/work/arrow/arrow/build/c_glib 
-I/Users/runner/work/arrow/arrow/c_glib -Iarrow-glib -I../../c_glib/arrow-glib 
-I/usr/local/Cellar/glib/2.80.0_2/include 
-I/usr/local/Cellar/glib/2.80.0_2/include/glib-2.0 
-I/usr/local/Cellar/glib/2.80.0_2/lib/glib-2.0/include 
-I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre2/10.43/include 
-I/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/inc [...]
    ../../c_glib/example/vala/read-file.vala:123:61: error: format specifies 
type 'long long' but the argument has type 'gint' (aka 'int') [-Werror,-Wformat]
                                    fprintf (_tmp2_, "columns[%" 
G_GINT64_FORMAT "](%s): ", nth_column, _tmp3_);
                                                              
~~~~~~~~~~~~~~~~~~            ^~~~~~~~~~
    1 error generated.
    ```
    
    ```text
    FAILED: example/vala/read-stream.p/meson-generated_read-stream.c.o
    ccache cc -Iexample/vala/read-stream.p -Iexample/vala 
-I../../c_glib/example/vala -I/Users/runner/work/arrow/arrow/build/c_glib 
-I/Users/runner/work/arrow/arrow/c_glib -Iarrow-glib -I../../c_glib/arrow-glib 
-I/usr/local/Cellar/glib/2.80.0_2/include 
-I/usr/local/Cellar/glib/2.80.0_2/include/glib-2.0 
-I/usr/local/Cellar/glib/2.80.0_2/lib/glib-2.0/include 
-I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre2/10.43/include 
-I/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/i [...]
    ../../c_glib/example/vala/read-stream.vala:123:61: error: format specifies 
type 'long long' but the argument has type 'gint' (aka 'int') [-Werror,-Wformat]
                                    fprintf (_tmp2_, "columns[%" 
G_GINT64_FORMAT "](%s): ", nth_column, _tmp3_);
                                                              
~~~~~~~~~~~~~~~~~~            ^~~~~~~~~~
    1 error generated.
    ```
    
    ```text
    FAILED: example/vala/write-file.p/meson-generated_write-file.c.o
    ccache cc -Iexample/vala/write-file.p -Iexample/vala 
-I../../c_glib/example/vala -I/Users/runner/work/arrow/arrow/build/c_glib 
-I/Users/runner/work/arrow/arrow/c_glib -Iarrow-glib -I../../c_glib/arrow-glib 
-I/usr/local/Cellar/glib/2.80.0_2/include 
-I/usr/local/Cellar/glib/2.80.0_2/include/glib-2.0 
-I/usr/local/Cellar/glib/2.80.0_2/lib/glib-2.0/include 
-I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre2/10.43/include 
-I/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/in [...]
    write-file.c:373:8: error: variable '_tmp45__length1' set but not used 
[-Werror,-Wunused-but-set-variable]
                    gint _tmp45__length1;
                         ^
    write-file.c:504:8: error: variable '_tmp57__length1' set but not used 
[-Werror,-Wunused-but-set-variable]
                    gint _tmp57__length1;
                         ^
    write-file.c:635:8: error: variable '_tmp69__length1' set but not used 
[-Werror,-Wunused-but-set-variable]
                    gint _tmp69__length1;
                         ^
    write-file.c:766:8: error: variable '_tmp81__length1' set but not used 
[-Werror,-Wunused-but-set-variable]
                    gint _tmp81__length1;
                         ^
    write-file.c:897:8: error: variable '_tmp93__length1' set but not used 
[-Werror,-Wunused-but-set-variable]
                    gint _tmp93__length1;
                         ^
    write-file.c:1028:8: error: variable '_tmp105__length1' set but not used 
[-Werror,-Wunused-but-set-variable]
                    gint _tmp105__length1;
                         ^
    write-file.c:1159:8: error: variable '_tmp117__length1' set but not used 
[-Werror,-Wunused-but-set-variable]
                    gint _tmp117__length1;
                         ^
    write-file.c:1290:8: error: variable '_tmp129__length1' set but not used 
[-Werror,-Wunused-but-set-variable]
                    gint _tmp129__length1;
                         ^
    write-file.c:1421:8: error: variable '_tmp141__length1' set but not used 
[-Werror,-Wunused-but-set-variable]
                    gint _tmp141__length1;
                         ^
    write-file.c:1552:8: error: variable '_tmp153__length1' set but not used 
[-Werror,-Wunused-but-set-variable]
                    gint _tmp153__length1;
                         ^
    10 errors generated.
    ```
    
    ### What changes are included in this PR?
    
    * Fix wrong format string
    * Disable `unused-but-set-variable` warning
    
    ### Are these changes tested?
    
    Yes.
    
    ### Are there any user-facing changes?
    
    No.
    * GitHub Issue: #40961
    
    Authored-by: Sutou Kouhei <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 c_glib/example/vala/meson.build      | 6 +++++-
 c_glib/example/vala/read-file.vala   | 4 ++--
 c_glib/example/vala/read-stream.vala | 4 ++--
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/c_glib/example/vala/meson.build b/c_glib/example/vala/meson.build
index 474f0b1e9a..ff65a7328f 100644
--- a/c_glib/example/vala/meson.build
+++ b/c_glib/example/vala/meson.build
@@ -18,11 +18,15 @@
 # under the License.
 
 if generate_vapi
+  c_flags = [
+    '-Wunused-but-set-variable',
+  ]
+  c_flags = meson.get_compiler('c').get_supported_arguments(c_flags)
   vala_example_executable_kwargs = {
     'c_args': [
       '-I' + project_build_root,
       '-I' + project_source_root,
-    ],
+    ] + c_flags,
     'dependencies': [
       arrow_glib_vapi,
       dependency('gio-2.0'),
diff --git a/c_glib/example/vala/read-file.vala 
b/c_glib/example/vala/read-file.vala
index a0a06275c4..287eddac76 100644
--- a/c_glib/example/vala/read-file.vala
+++ b/c_glib/example/vala/read-file.vala
@@ -119,8 +119,8 @@ void print_array(GArrow.Array array) {
 
 void print_record_batch(GArrow.RecordBatch record_batch) {
     var n_columns = record_batch.get_n_columns();
-    for (var nth_column = 0; nth_column < n_columns; nth_column++) {
-        stdout.printf("columns[%" + int64.FORMAT + "](%s): ",
+    for (int nth_column = 0; nth_column < n_columns; nth_column++) {
+        stdout.printf("columns[%d](%s): ",
                       nth_column,
                       record_batch.get_column_name(nth_column));
         var array = record_batch.get_column_data(nth_column);
diff --git a/c_glib/example/vala/read-stream.vala 
b/c_glib/example/vala/read-stream.vala
index c58dc84893..4520c8609b 100644
--- a/c_glib/example/vala/read-stream.vala
+++ b/c_glib/example/vala/read-stream.vala
@@ -119,8 +119,8 @@ void print_array(GArrow.Array array) {
 
 void print_record_batch(GArrow.RecordBatch record_batch) {
     var n_columns = record_batch.get_n_columns();
-    for (var nth_column = 0; nth_column < n_columns; nth_column++) {
-        stdout.printf("columns[%" + int64.FORMAT + "](%s): ",
+    for (int nth_column = 0; nth_column < n_columns; nth_column++) {
+        stdout.printf("columns[%d](%s): ",
                       nth_column,
                       record_batch.get_column_name(nth_column));
         var array = record_batch.get_column_data(nth_column);

Reply via email to