]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Avoid temporary variables for calls to [FormatArg] methods
authorJürg Billeter <j@bitron.ch>
Tue, 1 Nov 2016 17:03:17 +0000 (18:03 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 3 Nov 2016 19:47:31 +0000 (20:47 +0100)
This prevents bogus C compiler warnings with -Wformat-nonliteral.

https://bugzilla.gnome.org/show_bug.cgi?id=769229

codegen/valaccodemethodcallmodule.vala

index 2cd12b69f23afdf18499d67eb1ba17522411d1a9..7786d1bf9485a731d0df21b5cb4d36665fb41b7c 100644 (file)
@@ -787,7 +787,9 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                                }
                        }
 
-                       if (!return_result_via_out_param) {
+                       if (m != null && m.get_format_arg_index () >= 0) {
+                               set_cvalue (expr, ccall_expr);
+                       } else if (!return_result_via_out_param) {
                                var temp_var = get_temp_variable (result_type, result_type.value_owned);
                                var temp_ref = get_variable_cexpression (temp_var.name);
 
@@ -795,10 +797,11 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 
                                ccode.add_assignment (temp_ref, ccall_expr);
                                set_cvalue (expr, temp_ref);
+                               ((GLibValue) expr.target_value).lvalue = true;
                        } else {
                                set_cvalue (expr, ccall_expr);
+                               ((GLibValue) expr.target_value).lvalue = true;
                        }
-                       ((GLibValue) expr.target_value).lvalue = true;
                }
 
                params_it = params.iterator ();