ARC: fix build warnings
authorVineet Gupta <vgupta@synopsys.com>
Tue, 7 May 2019 17:45:24 +0000 (10:45 -0700)
committerVineet Gupta <vgupta@synopsys.com>
Mon, 20 May 2019 17:09:10 +0000 (10:09 -0700)
| arch/arc/mm/tlb.c:914:2: warning: variable length array 'pd0' is used [-Wvla]
| arch/arc/include/asm/cmpxchg.h:95:29: warning: value computed is not used [-Wunused-value]

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
arch/arc/include/asm/cmpxchg.h
arch/arc/mm/tlb.c

index d819de1c5d10ed21d951a4cf18a7cef75370e1de..3ea4112c8302a8b71b3dc7e473fd7e78d3992b1d 100644 (file)
@@ -92,8 +92,11 @@ __cmpxchg(volatile void *ptr, unsigned long expected, unsigned long new)
 
 #endif /* CONFIG_ARC_HAS_LLSC */
 
-#define cmpxchg(ptr, o, n) ((typeof(*(ptr)))__cmpxchg((ptr), \
-                               (unsigned long)(o), (unsigned long)(n)))
+#define cmpxchg(ptr, o, n) ({                          \
+       (typeof(*(ptr)))__cmpxchg((ptr),                \
+                                 (unsigned long)(o),   \
+                                 (unsigned long)(n));  \
+})
 
 /*
  * atomic_cmpxchg is same as cmpxchg
@@ -198,8 +201,11 @@ static inline unsigned long __xchg(unsigned long val, volatile void *ptr,
        return __xchg_bad_pointer();
 }
 
-#define xchg(ptr, with) ((typeof(*(ptr)))__xchg((unsigned long)(with), (ptr), \
-                                                sizeof(*(ptr))))
+#define xchg(ptr, with) ({                             \
+       (typeof(*(ptr)))__xchg((unsigned long)(with),   \
+                              (ptr),                   \
+                              sizeof(*(ptr)));         \
+})
 
 #endif /* CONFIG_ARC_PLAT_EZNPS */
 
index 4097764fea23499a828a559f70a62a29daba14c8..fa18c00b0cfd7de6afc7985ff5a67161608f89b0 100644 (file)
@@ -911,9 +911,11 @@ void do_tlb_overlap_fault(unsigned long cause, unsigned long address,
                          struct pt_regs *regs)
 {
        struct cpuinfo_arc_mmu *mmu = &cpuinfo_arc700[smp_processor_id()].mmu;
-       unsigned int pd0[mmu->ways];
        unsigned long flags;
-       int set;
+       int set, n_ways = mmu->ways;
+
+       n_ways = min(n_ways, 4);
+       BUG_ON(mmu->ways > 4);
 
        local_irq_save(flags);
 
@@ -921,9 +923,10 @@ void do_tlb_overlap_fault(unsigned long cause, unsigned long address,
        for (set = 0; set < mmu->sets; set++) {
 
                int is_valid, way;
+               unsigned int pd0[4];
 
                /* read out all the ways of current set */
-               for (way = 0, is_valid = 0; way < mmu->ways; way++) {
+               for (way = 0, is_valid = 0; way < n_ways; way++) {
                        write_aux_reg(ARC_REG_TLBINDEX,
                                          SET_WAY_TO_IDX(mmu, set, way));
                        write_aux_reg(ARC_REG_TLBCOMMAND, TLBRead);
@@ -937,14 +940,14 @@ void do_tlb_overlap_fault(unsigned long cause, unsigned long address,
                        continue;
 
                /* Scan the set for duplicate ways: needs a nested loop */
-               for (way = 0; way < mmu->ways - 1; way++) {
+               for (way = 0; way < n_ways - 1; way++) {
 
                        int n;
 
                        if (!pd0[way])
                                continue;
 
-                       for (n = way + 1; n < mmu->ways; n++) {
+                       for (n = way + 1; n < n_ways; n++) {
                                if (pd0[way] != pd0[n])
                                        continue;