Skip to content

Commit d873152

Browse files
malaterrempe
authored andcommitted
powerpc/sparse: Fix plain integer as NULL pointer warning
Trivial fix to remove the following sparse warnings: arch/powerpc/kernel/module_32.c:112:74: warning: Using plain integer as NULL pointer arch/powerpc/kernel/module_32.c:117:74: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:1155:28: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:1230:20: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:1385:36: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:1752:23: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:2084:19: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:2110:32: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:2167:19: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:2183:19: warning: Using plain integer as NULL pointer drivers/macintosh/via-pmu.c:277:20: warning: Using plain integer as NULL pointer arch/powerpc/platforms/powermac/setup.c:155:67: warning: Using plain integer as NULL pointer arch/powerpc/platforms/powermac/setup.c:247:27: warning: Using plain integer as NULL pointer arch/powerpc/platforms/powermac/setup.c:249:27: warning: Using plain integer as NULL pointer arch/powerpc/platforms/powermac/setup.c:252:37: warning: Using plain integer as NULL pointer arch/powerpc/mm/tlb_hash32.c:127:21: warning: Using plain integer as NULL pointer arch/powerpc/mm/tlb_hash32.c:148:21: warning: Using plain integer as NULL pointer arch/powerpc/mm/tlb_hash32.c:44:21: warning: Using plain integer as NULL pointer arch/powerpc/mm/tlb_hash32.c:57:21: warning: Using plain integer as NULL pointer arch/powerpc/mm/tlb_hash32.c:87:21: warning: Using plain integer as NULL pointer arch/powerpc/kernel/btext.c:160:31: warning: Using plain integer as NULL pointer arch/powerpc/kernel/btext.c:167:22: warning: Using plain integer as NULL pointer arch/powerpc/kernel/btext.c:274:21: warning: Using plain integer as NULL pointer arch/powerpc/kernel/btext.c:285:31: warning: Using plain integer as NULL pointer arch/powerpc/include/asm/hugetlb.h:204:16: warning: Using plain integer as NULL pointer arch/powerpc/mm/ppc_mmu_32.c:170:21: warning: Using plain integer as NULL pointer arch/powerpc/platforms/powermac/pci.c:1227:23: warning: Using plain integer as NULL pointer arch/powerpc/platforms/powermac/pci.c:65:24: warning: Using plain integer as NULL pointer Also use `--fix` command line option from `script/checkpatch --strict` to remove the following: CHECK: Comparison to NULL could be written "!dispDeviceBase" rockchip-linux#72: FILE: arch/powerpc/kernel/btext.c:160: + if (dispDeviceBase == NULL) CHECK: Comparison to NULL could be written "!vbase" rockchip-linux#80: FILE: arch/powerpc/kernel/btext.c:167: + if (vbase == NULL) CHECK: Comparison to NULL could be written "!base" rockchip-linux#89: FILE: arch/powerpc/kernel/btext.c:274: + if (base == NULL) CHECK: Comparison to NULL could be written "!dispDeviceBase" rockchip-linux#98: FILE: arch/powerpc/kernel/btext.c:285: + if (dispDeviceBase == NULL) CHECK: Comparison to NULL could be written "strstr" rockchip-linux#117: FILE: arch/powerpc/kernel/module_32.c:117: + if (strstr(secstrings + sechdrs[i].sh_name, ".debug") != NULL) CHECK: Comparison to NULL could be written "!Hash" rockchip-linux#130: FILE: arch/powerpc/mm/ppc_mmu_32.c:170: + if (Hash == NULL) CHECK: Comparison to NULL could be written "Hash" rockchip-linux#143: FILE: arch/powerpc/mm/tlb_hash32.c:44: + if (Hash != NULL) { CHECK: Comparison to NULL could be written "!Hash" rockchip-linux#152: FILE: arch/powerpc/mm/tlb_hash32.c:57: + if (Hash == NULL) { CHECK: Comparison to NULL could be written "!Hash" rockchip-linux#161: FILE: arch/powerpc/mm/tlb_hash32.c:87: + if (Hash == NULL) { CHECK: Comparison to NULL could be written "!Hash" rockchip-linux#170: FILE: arch/powerpc/mm/tlb_hash32.c:127: + if (Hash == NULL) { CHECK: Comparison to NULL could be written "!Hash" rockchip-linux#179: FILE: arch/powerpc/mm/tlb_hash32.c:148: + if (Hash == NULL) { ERROR: space required after that ';' (ctx:VxV) rockchip-linux#192: FILE: arch/powerpc/platforms/powermac/pci.c:65: + for (; node != NULL;node = node->sibling) { CHECK: Comparison to NULL could be written "node" rockchip-linux#192: FILE: arch/powerpc/platforms/powermac/pci.c:65: + for (; node != NULL;node = node->sibling) { CHECK: Comparison to NULL could be written "!region" rockchip-linux#201: FILE: arch/powerpc/platforms/powermac/pci.c:1227: + if (region == NULL) CHECK: Comparison to NULL could be written "of_get_property" rockchip-linux#214: FILE: arch/powerpc/platforms/powermac/setup.c:155: + if (of_get_property(np, "cache-unified", NULL) != NULL && dc) { CHECK: Comparison to NULL could be written "!np" rockchip-linux#223: FILE: arch/powerpc/platforms/powermac/setup.c:247: + if (np == NULL) CHECK: Comparison to NULL could be written "np" rockchip-linux#226: FILE: arch/powerpc/platforms/powermac/setup.c:249: + if (np != NULL) { CHECK: Comparison to NULL could be written "l2cr" rockchip-linux#230: FILE: arch/powerpc/platforms/powermac/setup.c:252: + if (l2cr != NULL) { CHECK: Comparison to NULL could be written "via" rockchip-linux#243: FILE: drivers/macintosh/via-pmu.c:277: + if (via != NULL) CHECK: Comparison to NULL could be written "current_req" rockchip-linux#252: FILE: drivers/macintosh/via-pmu.c:1155: + if (current_req != NULL) { CHECK: Comparison to NULL could be written "!req" rockchip-linux#261: FILE: drivers/macintosh/via-pmu.c:1230: + if (req == NULL || pmu_state != idle CHECK: Comparison to NULL could be written "!req" rockchip-linux#270: FILE: drivers/macintosh/via-pmu.c:1385: + if (req == NULL) { CHECK: Comparison to NULL could be written "!pp" rockchip-linux#288: FILE: drivers/macintosh/via-pmu.c:2084: + if (pp == NULL) CHECK: Comparison to NULL could be written "!pp" rockchip-linux#297: FILE: drivers/macintosh/via-pmu.c:2110: + if (count < 1 || pp == NULL) CHECK: Comparison to NULL could be written "!pp" rockchip-linux#306: FILE: drivers/macintosh/via-pmu.c:2167: + if (pp == NULL) CHECK: Comparison to NULL could be written "pp" rockchip-linux#315: FILE: drivers/macintosh/via-pmu.c:2183: + if (pp != NULL) { Link: https://github.com/linuxppc/linux/issues/37 Signed-off-by: Mathieu Malaterre <malat@debian.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 7cf76a6 commit d873152

8 files changed

Lines changed: 28 additions & 28 deletions

File tree

arch/powerpc/include/asm/hugetlb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static inline void flush_hugetlb_page(struct vm_area_struct *vma,
202202
static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr,
203203
unsigned pdshift)
204204
{
205-
return 0;
205+
return NULL;
206206
}
207207
#endif /* CONFIG_HUGETLB_PAGE */
208208

arch/powerpc/kernel/btext.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ void btext_map(void)
157157

158158
/* By default, we are no longer mapped */
159159
boot_text_mapped = 0;
160-
if (dispDeviceBase == 0)
160+
if (!dispDeviceBase)
161161
return;
162162
base = ((unsigned long) dispDeviceBase) & 0xFFFFF000UL;
163163
offset = ((unsigned long) dispDeviceBase) - base;
164164
size = dispDeviceRowBytes * dispDeviceRect[3] + offset
165165
+ dispDeviceRect[0];
166166
vbase = __ioremap(base, size, pgprot_val(pgprot_noncached_wc(__pgprot(0))));
167-
if (vbase == 0)
167+
if (!vbase)
168168
return;
169169
logicalDisplayBase = vbase + offset;
170170
boot_text_mapped = 1;
@@ -270,7 +270,7 @@ static unsigned char * calc_base(int x, int y)
270270
unsigned char *base;
271271

272272
base = logicalDisplayBase;
273-
if (base == 0)
273+
if (!base)
274274
base = dispDeviceBase;
275275
base += (x + dispDeviceRect[0]) * (dispDeviceDepth >> 3);
276276
base += (y + dispDeviceRect[1]) * dispDeviceRowBytes;
@@ -281,7 +281,7 @@ static unsigned char * calc_base(int x, int y)
281281
void btext_update_display(unsigned long phys, int width, int height,
282282
int depth, int pitch)
283283
{
284-
if (dispDeviceBase == 0)
284+
if (!dispDeviceBase)
285285
return;
286286

287287
/* check it's the same frame buffer (within 256MB) */

arch/powerpc/kernel/module_32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ static unsigned long get_plt_size(const Elf32_Ehdr *hdr,
109109
for (i = 1; i < hdr->e_shnum; i++) {
110110
/* If it's called *.init*, and we're not init, we're
111111
not interested */
112-
if ((strstr(secstrings + sechdrs[i].sh_name, ".init") != 0)
112+
if ((strstr(secstrings + sechdrs[i].sh_name, ".init") != NULL)
113113
!= is_init)
114114
continue;
115115

116116
/* We don't want to look at debug sections. */
117-
if (strstr(secstrings + sechdrs[i].sh_name, ".debug") != 0)
117+
if (strstr(secstrings + sechdrs[i].sh_name, ".debug"))
118118
continue;
119119

120120
if (sechdrs[i].sh_type == SHT_RELA) {

arch/powerpc/mm/ppc_mmu_32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,
167167
{
168168
pmd_t *pmd;
169169

170-
if (Hash == 0)
170+
if (!Hash)
171171
return;
172172
pmd = pmd_offset(pud_offset(pgd_offset(mm, ea), ea), ea);
173173
if (!pmd_none(*pmd))

arch/powerpc/mm/tlb_hash32.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void flush_hash_entry(struct mm_struct *mm, pte_t *ptep, unsigned long addr)
4141
{
4242
unsigned long ptephys;
4343

44-
if (Hash != 0) {
44+
if (Hash) {
4545
ptephys = __pa(ptep) & PAGE_MASK;
4646
flush_hash_pages(mm->context.id, addr, ptephys, 1);
4747
}
@@ -54,7 +54,7 @@ EXPORT_SYMBOL(flush_hash_entry);
5454
*/
5555
void tlb_flush(struct mmu_gather *tlb)
5656
{
57-
if (Hash == 0) {
57+
if (!Hash) {
5858
/*
5959
* 603 needs to flush the whole TLB here since
6060
* it doesn't use a hash table.
@@ -84,7 +84,7 @@ static void flush_range(struct mm_struct *mm, unsigned long start,
8484
int count;
8585
unsigned int ctx = mm->context.id;
8686

87-
if (Hash == 0) {
87+
if (!Hash) {
8888
_tlbia();
8989
return;
9090
}
@@ -124,7 +124,7 @@ void flush_tlb_mm(struct mm_struct *mm)
124124
{
125125
struct vm_area_struct *mp;
126126

127-
if (Hash == 0) {
127+
if (!Hash) {
128128
_tlbia();
129129
return;
130130
}
@@ -145,7 +145,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr)
145145
struct mm_struct *mm;
146146
pmd_t *pmd;
147147

148-
if (Hash == 0) {
148+
if (!Hash) {
149149
_tlbie(vmaddr);
150150
return;
151151
}

arch/powerpc/platforms/powermac/pci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct device_node *k2_skiplist[2];
6262

6363
static int __init fixup_one_level_bus_range(struct device_node *node, int higher)
6464
{
65-
for (; node != 0;node = node->sibling) {
65+
for (; node; node = node->sibling) {
6666
const int * bus_range;
6767
const unsigned int *class_code;
6868
int len;
@@ -1219,7 +1219,7 @@ static void fixup_u4_pcie(struct pci_dev* dev)
12191219
region = r;
12201220
}
12211221
/* Nothing found, bail */
1222-
if (region == 0)
1222+
if (!region)
12231223
return;
12241224

12251225
/* Print things out */

arch/powerpc/platforms/powermac/setup.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static void pmac_show_cpuinfo(struct seq_file *m)
152152
of_get_property(np, "d-cache-size", NULL);
153153
seq_printf(m, "L2 cache\t:");
154154
has_l2cache = 1;
155-
if (of_get_property(np, "cache-unified", NULL) != 0 && dc) {
155+
if (of_get_property(np, "cache-unified", NULL) && dc) {
156156
seq_printf(m, " %dK unified", *dc / 1024);
157157
} else {
158158
if (ic)
@@ -244,12 +244,12 @@ static void __init l2cr_init(void)
244244
/* Checks "l2cr-value" property in the registry */
245245
if (cpu_has_feature(CPU_FTR_L2CR)) {
246246
struct device_node *np = of_find_node_by_name(NULL, "cpus");
247-
if (np == 0)
247+
if (!np)
248248
np = of_find_node_by_type(NULL, "cpu");
249-
if (np != 0) {
249+
if (np) {
250250
const unsigned int *l2cr =
251251
of_get_property(np, "l2cr-value", NULL);
252-
if (l2cr != 0) {
252+
if (l2cr) {
253253
ppc_override_l2cr = 1;
254254
ppc_override_l2cr_value = *l2cr;
255255
_set_L2CR(0);

drivers/macintosh/via-pmu.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ int __init find_via_pmu(void)
274274
u64 taddr;
275275
const u32 *reg;
276276

277-
if (via != 0)
277+
if (via)
278278
return 1;
279279
vias = of_find_node_by_name(NULL, "via-pmu");
280280
if (vias == NULL)
@@ -1152,7 +1152,7 @@ pmu_queue_request(struct adb_request *req)
11521152
req->complete = 0;
11531153

11541154
spin_lock_irqsave(&pmu_lock, flags);
1155-
if (current_req != 0) {
1155+
if (current_req) {
11561156
last_req->next = req;
11571157
last_req = req;
11581158
} else {
@@ -1227,7 +1227,7 @@ pmu_start(void)
12271227
/* assert pmu_state == idle */
12281228
/* get the packet to send */
12291229
req = current_req;
1230-
if (req == 0 || pmu_state != idle
1230+
if (!req || pmu_state != idle
12311231
|| (/*req->reply_expected && */req_awaiting_reply))
12321232
return;
12331233

@@ -1382,7 +1382,7 @@ pmu_handle_data(unsigned char *data, int len)
13821382
if ((1 << pirq) & PMU_INT_ADB) {
13831383
if ((data[0] & PMU_INT_ADB_AUTO) == 0) {
13841384
struct adb_request *req = req_awaiting_reply;
1385-
if (req == 0) {
1385+
if (!req) {
13861386
printk(KERN_ERR "PMU: extra ADB reply\n");
13871387
return;
13881388
}
@@ -1749,7 +1749,7 @@ pmu_shutdown(void)
17491749
int
17501750
pmu_present(void)
17511751
{
1752-
return via != 0;
1752+
return via != NULL;
17531753
}
17541754

17551755
#if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32)
@@ -2081,7 +2081,7 @@ pmu_open(struct inode *inode, struct file *file)
20812081
unsigned long flags;
20822082

20832083
pp = kmalloc(sizeof(struct pmu_private), GFP_KERNEL);
2084-
if (pp == 0)
2084+
if (!pp)
20852085
return -ENOMEM;
20862086
pp->rb_get = pp->rb_put = 0;
20872087
spin_lock_init(&pp->lock);
@@ -2107,7 +2107,7 @@ pmu_read(struct file *file, char __user *buf,
21072107
unsigned long flags;
21082108
int ret = 0;
21092109

2110-
if (count < 1 || pp == 0)
2110+
if (count < 1 || !pp)
21112111
return -EINVAL;
21122112
if (!access_ok(VERIFY_WRITE, buf, count))
21132113
return -EFAULT;
@@ -2164,7 +2164,7 @@ pmu_fpoll(struct file *filp, poll_table *wait)
21642164
__poll_t mask = 0;
21652165
unsigned long flags;
21662166

2167-
if (pp == 0)
2167+
if (!pp)
21682168
return 0;
21692169
poll_wait(filp, &pp->wait, wait);
21702170
spin_lock_irqsave(&pp->lock, flags);
@@ -2180,7 +2180,7 @@ pmu_release(struct inode *inode, struct file *file)
21802180
struct pmu_private *pp = file->private_data;
21812181
unsigned long flags;
21822182

2183-
if (pp != 0) {
2183+
if (pp) {
21842184
file->private_data = NULL;
21852185
spin_lock_irqsave(&all_pvt_lock, flags);
21862186
list_del(&pp->list);

0 commit comments

Comments
 (0)