|
From: | Richard Henderson |
Subject: | Re: [PATCH v1 25/43] target/loongarch: Add LoongArch CSR instruction |
Date: | Mon, 18 Apr 2022 07:34:20 -0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 |
On 4/18/22 05:38, yangxiaojuan wrote:
On 2022/4/16 上午9:04, Richard Henderson wrote:+int cpu_csr_offset(unsigned csr_num);...+static const uint64_t csr_offsets[] = {There's no reason for this array to be uint64_t.It really should match the function.Yes, we shoud do this. If we use 'int', we may get a warning:../target/loongarch/csr_helper.c:49:30: warning: overflow in implicit constant conversion [-Woverflow][LOONGARCH_CSR_CPUID] = offsetof(CPUState, cpu_index) ^~~~~~~~ How about use 'long'? I had tested it no warning.
That is because offsetof() result is size_t, which is unsigned, and a "negative" unsigned number is a large positive. Cast each offsetof to int.
r~
[Prev in Thread] | Current Thread | [Next in Thread] |