[PATCH 2/3] error-report: move real_time_iso8601() to header

Vladimir Sementsov-Ogievskiy posted 3 patches 2 months, 1 week ago
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Markus Armbruster <armbru@redhat.com>, Eric Blake <eblake@redhat.com>
There is a newer version of this series
[PATCH 2/3] error-report: move real_time_iso8601() to header
Posted by Vladimir Sementsov-Ogievskiy 2 months, 1 week ago
To be reused in the following commit.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 include/qemu/error-report.h | 6 ++++++
 util/error-report.c         | 7 -------
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
index 3ae2357fda..412b705898 100644
--- a/include/qemu/error-report.h
+++ b/include/qemu/error-report.h
@@ -74,4 +74,10 @@ extern bool message_with_timestamp;
 extern bool error_with_guestname;
 extern const char *error_guest_name;
 
+static inline char *real_time_iso8601(void)
+{
+    g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
+    return g_date_time_format_iso8601(dt);
+}
+
 #endif
diff --git a/util/error-report.c b/util/error-report.c
index 1b17c11de1..20618640e8 100644
--- a/util/error-report.c
+++ b/util/error-report.c
@@ -169,13 +169,6 @@ static void print_loc(void)
     }
 }
 
-static char *
-real_time_iso8601(void)
-{
-    g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
-    return g_date_time_format_iso8601(dt);
-}
-
 /*
  * Print a message to current monitor if we have one, else to stderr.
  * @report_type is the type of message: error, warning or informational.
-- 
2.48.1
Re: [PATCH 2/3] error-report: move real_time_iso8601() to header
Posted by Markus Armbruster 2 months, 1 week ago
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:

> To be reused in the following commit.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>  include/qemu/error-report.h | 6 ++++++
>  util/error-report.c         | 7 -------
>  2 files changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
> index 3ae2357fda..412b705898 100644
> --- a/include/qemu/error-report.h
> +++ b/include/qemu/error-report.h
> @@ -74,4 +74,10 @@ extern bool message_with_timestamp;
>  extern bool error_with_guestname;
>  extern const char *error_guest_name;
>  
> +static inline char *real_time_iso8601(void)
> +{
> +    g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
> +    return g_date_time_format_iso8601(dt);
> +}
> +
>  #endif

Reasons for inline?  Because the function is so small?

> diff --git a/util/error-report.c b/util/error-report.c
> index 1b17c11de1..20618640e8 100644
> --- a/util/error-report.c
> +++ b/util/error-report.c
> @@ -169,13 +169,6 @@ static void print_loc(void)
>      }
>  }
>  
> -static char *
> -real_time_iso8601(void)
> -{
> -    g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
> -    return g_date_time_format_iso8601(dt);
> -}
> -
>  /*
>   * Print a message to current monitor if we have one, else to stderr.
>   * @report_type is the type of message: error, warning or informational.
Re: [PATCH 2/3] error-report: move real_time_iso8601() to header
Posted by Vladimir Sementsov-Ogievskiy 2 months, 1 week ago
On 03.12.25 17:16, Markus Armbruster wrote:
> Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:
> 
>> To be reused in the following commit.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
>> ---
>>   include/qemu/error-report.h | 6 ++++++
>>   util/error-report.c         | 7 -------
>>   2 files changed, 6 insertions(+), 7 deletions(-)
>>
>> diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
>> index 3ae2357fda..412b705898 100644
>> --- a/include/qemu/error-report.h
>> +++ b/include/qemu/error-report.h
>> @@ -74,4 +74,10 @@ extern bool message_with_timestamp;
>>   extern bool error_with_guestname;
>>   extern const char *error_guest_name;
>>   
>> +static inline char *real_time_iso8601(void)
>> +{
>> +    g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
>> +    return g_date_time_format_iso8601(dt);
>> +}
>> +
>>   #endif
> 
> Reasons for inline?  Because the function is so small?

Yes, seems, just this.

> 
>> diff --git a/util/error-report.c b/util/error-report.c
>> index 1b17c11de1..20618640e8 100644
>> --- a/util/error-report.c
>> +++ b/util/error-report.c
>> @@ -169,13 +169,6 @@ static void print_loc(void)
>>       }
>>   }
>>   
>> -static char *
>> -real_time_iso8601(void)
>> -{
>> -    g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
>> -    return g_date_time_format_iso8601(dt);
>> -}
>> -
>>   /*
>>    * Print a message to current monitor if we have one, else to stderr.
>>    * @report_type is the type of message: error, warning or informational.
> 


-- 
Best regards,
Vladimir
Re: [PATCH 2/3] error-report: move real_time_iso8601() to header
Posted by Markus Armbruster 2 months, 1 week ago
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:

> On 03.12.25 17:16, Markus Armbruster wrote:
>> Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:
>> 
>>> To be reused in the following commit.
>>>
>>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
>>> ---
>>>   include/qemu/error-report.h | 6 ++++++
>>>   util/error-report.c         | 7 -------
>>>   2 files changed, 6 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
>>> index 3ae2357fda..412b705898 100644
>>> --- a/include/qemu/error-report.h
>>> +++ b/include/qemu/error-report.h
>>> @@ -74,4 +74,10 @@ extern bool message_with_timestamp;
>>>   extern bool error_with_guestname;
>>>   extern const char *error_guest_name;
>>>   
>>> +static inline char *real_time_iso8601(void)
>>> +{
>>> +    g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
>>> +    return g_date_time_format_iso8601(dt);
>>> +}
>>> +
>>>   #endif
>> 
>> Reasons for inline?  Because the function is so small?
>
> Yes, seems, just this.

I'd prefer not to.

Actually, I'd be tempted to just duplicate the two calls and call it a
day.  Up to you.

>>> diff --git a/util/error-report.c b/util/error-report.c
>>> index 1b17c11de1..20618640e8 100644
>>> --- a/util/error-report.c
>>> +++ b/util/error-report.c
>>> @@ -169,13 +169,6 @@ static void print_loc(void)
>>>       }
>>>   }
>>>   
>>> -static char *
>>> -real_time_iso8601(void)
>>> -{
>>> -    g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
>>> -    return g_date_time_format_iso8601(dt);
>>> -}
>>> -
>>>   /*
>>>    * Print a message to current monitor if we have one, else to stderr.
>>>    * @report_type is the type of message: error, warning or informational.
>>
Re: [PATCH 2/3] error-report: move real_time_iso8601() to header
Posted by Philippe Mathieu-Daudé 2 months, 1 week ago
Hi,

On 4/12/25 09:12, Markus Armbruster wrote:
> Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:
> 
>> On 03.12.25 17:16, Markus Armbruster wrote:
>>> Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:
>>>
>>>> To be reused in the following commit.
>>>>
>>>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
>>>> ---
>>>>    include/qemu/error-report.h | 6 ++++++
>>>>    util/error-report.c         | 7 -------
>>>>    2 files changed, 6 insertions(+), 7 deletions(-)
>>>>
>>>> diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
>>>> index 3ae2357fda..412b705898 100644
>>>> --- a/include/qemu/error-report.h
>>>> +++ b/include/qemu/error-report.h
>>>> @@ -74,4 +74,10 @@ extern bool message_with_timestamp;
>>>>    extern bool error_with_guestname;
>>>>    extern const char *error_guest_name;
>>>>    
>>>> +static inline char *real_time_iso8601(void)
>>>> +{
>>>> +    g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
>>>> +    return g_date_time_format_iso8601(dt);
>>>> +}
>>>> +
>>>>    #endif
>>>
>>> Reasons for inline?  Because the function is so small?
>>
>> Yes, seems, just this.
> 
> I'd prefer not to.
> 
> Actually, I'd be tempted to just duplicate the two calls and call it a
> day.  Up to you.

We now prefer to let the toolchain LTO do its clever job.
Better avoid duplication. To enforce this style, lets expose
the declaration with a @docstring, and keep the definition in util/.
My 2 cents.

> 
>>>> diff --git a/util/error-report.c b/util/error-report.c
>>>> index 1b17c11de1..20618640e8 100644
>>>> --- a/util/error-report.c
>>>> +++ b/util/error-report.c
>>>> @@ -169,13 +169,6 @@ static void print_loc(void)
>>>>        }
>>>>    }
>>>>    
>>>> -static char *
>>>> -real_time_iso8601(void)
>>>> -{
>>>> -    g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
>>>> -    return g_date_time_format_iso8601(dt);
>>>> -}
Re: [PATCH 2/3] error-report: move real_time_iso8601() to header
Posted by Vladimir Sementsov-Ogievskiy 2 months, 1 week ago
On 04.12.25 11:30, Philippe Mathieu-Daudé wrote:
> Hi,
> 
> On 4/12/25 09:12, Markus Armbruster wrote:
>> Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:
>>
>>> On 03.12.25 17:16, Markus Armbruster wrote:
>>>> Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:
>>>>
>>>>> To be reused in the following commit.
>>>>>
>>>>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
>>>>> ---
>>>>>    include/qemu/error-report.h | 6 ++++++
>>>>>    util/error-report.c         | 7 -------
>>>>>    2 files changed, 6 insertions(+), 7 deletions(-)
>>>>>
>>>>> diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
>>>>> index 3ae2357fda..412b705898 100644
>>>>> --- a/include/qemu/error-report.h
>>>>> +++ b/include/qemu/error-report.h
>>>>> @@ -74,4 +74,10 @@ extern bool message_with_timestamp;
>>>>>    extern bool error_with_guestname;
>>>>>    extern const char *error_guest_name;
>>>>> +static inline char *real_time_iso8601(void)
>>>>> +{
>>>>> +    g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
>>>>> +    return g_date_time_format_iso8601(dt);
>>>>> +}
>>>>> +
>>>>>    #endif
>>>>
>>>> Reasons for inline?  Because the function is so small?
>>>
>>> Yes, seems, just this.
>>
>> I'd prefer not to.
>>
>> Actually, I'd be tempted to just duplicate the two calls and call it a
>> day.  Up to you.
> 
> We now prefer to let the toolchain LTO do its clever job.
> Better avoid duplication. To enforce this style, lets expose
> the declaration with a @docstring, and keep the definition in util/.
> My 2 cents.
> 

OK

>>
>>>>> diff --git a/util/error-report.c b/util/error-report.c
>>>>> index 1b17c11de1..20618640e8 100644
>>>>> --- a/util/error-report.c
>>>>> +++ b/util/error-report.c
>>>>> @@ -169,13 +169,6 @@ static void print_loc(void)
>>>>>        }
>>>>>    }
>>>>> -static char *
>>>>> -real_time_iso8601(void)
>>>>> -{
>>>>> -    g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
>>>>> -    return g_date_time_format_iso8601(dt);
>>>>> -}


-- 
Best regards,
Vladimir