Skip to content

Commit 62ae216

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: Don't open code ARRAY_SIZE()
Use ARRAY_SIZE() instead of an open-coded version. Signed-off-by: Oliver Upton <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Reviewed-by: Kalesh Singh <[email protected]> Tested-by: Kalesh Singh <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0e773da commit 62ae216

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

arch/arm64/kvm/hyp/nvhe/stacktrace.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,13 @@ static void notrace unwind(struct unwind_state *state,
103103
static bool pkvm_save_backtrace_entry(void *arg, unsigned long where)
104104
{
105105
unsigned long *stacktrace = this_cpu_ptr(pkvm_stacktrace);
106-
int size = NVHE_STACKTRACE_SIZE / sizeof(long);
107106
int *idx = (int *)arg;
108107

109108
/*
110109
* Need 2 free slots: 1 for current entry and 1 for the
111110
* delimiter.
112111
*/
113-
if (*idx > size - 2)
112+
if (*idx > ARRAY_SIZE(pkvm_stacktrace) - 2)
114113
return false;
115114

116115
stacktrace[*idx] = where;

arch/arm64/kvm/stacktrace.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,13 @@ static void pkvm_dump_backtrace(unsigned long hyp_offset)
187187
{
188188
unsigned long *stacktrace
189189
= (unsigned long *) this_cpu_ptr_nvhe_sym(pkvm_stacktrace);
190-
int i, size = NVHE_STACKTRACE_SIZE / sizeof(long);
190+
int i;
191191

192192
kvm_nvhe_dump_backtrace_start();
193193
/* The saved stacktrace is terminated by a null entry */
194-
for (i = 0; i < size && stacktrace[i]; i++)
194+
for (i = 0;
195+
i < ARRAY_SIZE(kvm_nvhe_sym(pkvm_stacktrace)) && stacktrace[i];
196+
i++)
195197
kvm_nvhe_dump_backtrace_entry((void *)hyp_offset, stacktrace[i]);
196198
kvm_nvhe_dump_backtrace_end();
197199
}

0 commit comments

Comments
 (0)