diff mbox series

[01/14] xen: Constify the second parameter of rangeset_new()

Message ID 20210405155713.29754-2-julien@xen.org (mailing list archive)
State New
Headers show
Series Use const whether we point to literal strings (take 1) | expand

Commit Message

Julien Grall April 5, 2021, 3:57 p.m. UTC
From: Julien Grall <jgrall@amazon.com>

The string 'name' will never get modified by the function, so mark it
as const.

Signed-off-by: Julien Grall <jgrall@amazon.com>
---
 xen/common/rangeset.c      | 2 +-
 xen/include/xen/rangeset.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Jan Beulich April 6, 2021, 7:57 a.m. UTC | #1
On 05.04.2021 17:57, Julien Grall wrote:
> From: Julien Grall <jgrall@amazon.com>
> 
> The string 'name' will never get modified by the function, so mark it
> as const.
> 
> Signed-off-by: Julien Grall <jgrall@amazon.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

> --- a/xen/common/rangeset.c
> +++ b/xen/common/rangeset.c
> @@ -421,7 +421,7 @@ bool_t rangeset_is_empty(
>  }
>  
>  struct rangeset *rangeset_new(
> -    struct domain *d, char *name, unsigned int flags)
> +    struct domain *d, const char *name, unsigned int flags)
>  {
>      struct rangeset *r;

Remotely along these lines the function also has no need anymore to
use snprintf() - safe_strcpy() very well fits both purposes. But
quite likely for another patch.

Jan
Julien Grall April 6, 2021, 6:03 p.m. UTC | #2
Hi Jan,

On 06/04/2021 08:57, Jan Beulich wrote:
> On 05.04.2021 17:57, Julien Grall wrote:
>> From: Julien Grall <jgrall@amazon.com>
>>
>> The string 'name' will never get modified by the function, so mark it
>> as const.
>>
>> Signed-off-by: Julien Grall <jgrall@amazon.com>
> 
> Reviewed-by: Jan Beulich <jbeulich@suse.com>

Thanks!

> 
>> --- a/xen/common/rangeset.c
>> +++ b/xen/common/rangeset.c
>> @@ -421,7 +421,7 @@ bool_t rangeset_is_empty(
>>   }
>>   
>>   struct rangeset *rangeset_new(
>> -    struct domain *d, char *name, unsigned int flags)
>> +    struct domain *d, const char *name, unsigned int flags)
>>   {
>>       struct rangeset *r;
> 
> Remotely along these lines the function also has no need anymore to
> use snprintf() - safe_strcpy() very well fits both purposes. But
> quite likely for another patch.

I saw you already sent the patch for that. So I am assuming there is no 
action for me here.

Cheers,
diff mbox series

Patch

diff --git a/xen/common/rangeset.c b/xen/common/rangeset.c
index 4ebba30ba303..d997d7bce9e2 100644
--- a/xen/common/rangeset.c
+++ b/xen/common/rangeset.c
@@ -421,7 +421,7 @@  bool_t rangeset_is_empty(
 }
 
 struct rangeset *rangeset_new(
-    struct domain *d, char *name, unsigned int flags)
+    struct domain *d, const char *name, unsigned int flags)
 {
     struct rangeset *r;
 
diff --git a/xen/include/xen/rangeset.h b/xen/include/xen/rangeset.h
index 5f62a9797170..135f33f6066f 100644
--- a/xen/include/xen/rangeset.h
+++ b/xen/include/xen/rangeset.h
@@ -36,7 +36,7 @@  void rangeset_domain_destroy(
  * rangeset_destroy(r).
  */
 struct rangeset *rangeset_new(
-    struct domain *d, char *name, unsigned int flags);
+    struct domain *d, const char *name, unsigned int flags);
 void rangeset_destroy(
     struct rangeset *r);