Message ID | 20210405155713.29754-4-julien@xen.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Use const whether we point to literal strings (take 1) | expand |
On Mon, Apr 05, 2021 at 04:57:02PM +0100, Julien Grall wrote: > From: Julien Grall <jgrall@amazon.com> > > The function sh_audit_flags() is returning pointer to literal strings. > They should not be modified, so the return is now const and this is > propagated to the callers. > > Take the opportunity to fix the coding style in the declaration of > sh_audit_flags. > > Signed-off-by: Julien Grall <jgrall@amazon.com> While doing the cleanup I think you could narrow the scope of the 's' variables also, but doesn't need to be part of this patch: Reviewed-by: Roger Pau Monné <roger.pau@citrix.com> Thanks, Roger.
At 16:57 +0100 on 05 Apr (1617641822), Julien Grall wrote: > From: Julien Grall <jgrall@amazon.com> > > The function sh_audit_flags() is returning pointer to literal strings. > They should not be modified, so the return is now const and this is > propagated to the callers. > > Take the opportunity to fix the coding style in the declaration of > sh_audit_flags. > > Signed-off-by: Julien Grall <jgrall@amazon.com> Acked-by: Tim Deegan <tim@xen.org> Thanks, Tim.
Hi Roger, On 06/04/2021 08:24, Roger Pau Monné wrote: > On Mon, Apr 05, 2021 at 04:57:02PM +0100, Julien Grall wrote: >> From: Julien Grall <jgrall@amazon.com> >> >> The function sh_audit_flags() is returning pointer to literal strings. >> They should not be modified, so the return is now const and this is >> propagated to the callers. >> >> Take the opportunity to fix the coding style in the declaration of >> sh_audit_flags. >> >> Signed-off-by: Julien Grall <jgrall@amazon.com> > > While doing the cleanup I think you could narrow the scope of the 's' > variables also, but doesn't need to be part of this patch: I think you are right. I will look at it as a follow-up. > Reviewed-by: Roger Pau Monné <roger.pau@citrix.com> Thanks for the review! Cheers,
diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index 9b43cb116c47..0342de81d2c1 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -4290,8 +4290,8 @@ static void sh_pagetable_dying(paddr_t gpa) done = 1; \ } while (0) -static char * sh_audit_flags(struct vcpu *v, int level, - int gflags, int sflags) +static const char *sh_audit_flags(struct vcpu *v, int level, + int gflags, int sflags) /* Common code for auditing flag bits */ { if ( (sflags & _PAGE_PRESENT) && !(gflags & _PAGE_PRESENT) ) @@ -4324,7 +4324,7 @@ int sh_audit_l1_table(struct vcpu *v, mfn_t sl1mfn, mfn_t x) mfn_t mfn, gmfn, gl1mfn; gfn_t gfn; p2m_type_t p2mt; - char *s; + const char *s; int done = 0; /* Follow the backpointer */ @@ -4419,7 +4419,7 @@ int sh_audit_l2_table(struct vcpu *v, mfn_t sl2mfn, mfn_t x) mfn_t mfn, gmfn, gl2mfn; gfn_t gfn; p2m_type_t p2mt; - char *s; + const char *s; int done = 0; /* Follow the backpointer */ @@ -4471,7 +4471,7 @@ int sh_audit_l3_table(struct vcpu *v, mfn_t sl3mfn, mfn_t x) mfn_t mfn, gmfn, gl3mfn; gfn_t gfn; p2m_type_t p2mt; - char *s; + const char *s; int done = 0; /* Follow the backpointer */ @@ -4521,7 +4521,7 @@ int sh_audit_l4_table(struct vcpu *v, mfn_t sl4mfn, mfn_t x) mfn_t mfn, gmfn, gl4mfn; gfn_t gfn; p2m_type_t p2mt; - char *s; + const char *s; int done = 0; /* Follow the backpointer */