Message ID | 20210405155713.29754-2-julien@xen.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Use const whether we point to literal strings (take 1) | expand |
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
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 --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);