Skip to content

Commit 8fd5926

Browse files
elfringehristev
authored andcommitted
media: drivers: Adjust checks for null pointers
The script “checkpatch.pl” pointed information out like the following. Comparison to NULL could be written !… Thus fix the affected source code places. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Hans Verkuil <hansverk@cisco.com>
1 parent 7acd119 commit 8fd5926

9 files changed

Lines changed: 44 additions & 44 deletions

File tree

drivers/media/common/siano/smscoreapi.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ static int smscore_sendrequest_and_wait(struct smscore_device_t *coredev,
749749
void *buffer, size_t size, struct completion *completion) {
750750
int rc;
751751

752-
if (completion == NULL)
752+
if (!completion)
753753
return -EINVAL;
754754
init_completion(completion);
755755

@@ -1151,8 +1151,8 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
11511151
}
11521152
pr_debug("Firmware name: %s\n", fw_filename);
11531153

1154-
if (loadfirmware_handler == NULL && !(coredev->device_flags
1155-
& SMS_DEVICE_FAMILY2))
1154+
if (!loadfirmware_handler &&
1155+
!(coredev->device_flags & SMS_DEVICE_FAMILY2))
11561156
return -EINVAL;
11571157

11581158
rc = request_firmware(&fw, fw_filename, coredev->device);
@@ -1789,15 +1789,15 @@ int smsclient_sendrequest(struct smscore_client_t *client,
17891789
struct sms_msg_hdr *phdr = (struct sms_msg_hdr *) buffer;
17901790
int rc;
17911791

1792-
if (client == NULL) {
1792+
if (!client) {
17931793
pr_err("Got NULL client\n");
17941794
return -EINVAL;
17951795
}
17961796

17971797
coredev = client->coredev;
17981798

17991799
/* check that no other channel with same id exists */
1800-
if (coredev == NULL) {
1800+
if (!coredev) {
18011801
pr_err("Got NULL coredev\n");
18021802
return -EINVAL;
18031803
}
@@ -1954,7 +1954,7 @@ int smscore_gpio_configure(struct smscore_device_t *coredev, u8 pin_num,
19541954
if (pin_num > MAX_GPIO_PIN_NUMBER)
19551955
return -EINVAL;
19561956

1957-
if (p_gpio_config == NULL)
1957+
if (!p_gpio_config)
19581958
return -EINVAL;
19591959

19601960
total_len = sizeof(struct sms_msg_hdr) + (sizeof(u32) * 6);

drivers/media/dvb-frontends/drxd_hard.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ static int WriteTable(struct drxd_state *state, u8 * pTable)
328328
{
329329
int status = 0;
330330

331-
if (pTable == NULL)
331+
if (!pTable)
332332
return 0;
333333

334334
while (!status) {
@@ -909,7 +909,7 @@ static int load_firmware(struct drxd_state *state, const char *fw_name)
909909
}
910910

911911
state->microcode = kmemdup(fw->data, fw->size, GFP_KERNEL);
912-
if (state->microcode == NULL) {
912+
if (!state->microcode) {
913913
release_firmware(fw);
914914
return -ENOMEM;
915915
}
@@ -2629,7 +2629,7 @@ static int DRXD_init(struct drxd_state *state, const u8 *fw, u32 fw_size)
26292629
break;
26302630

26312631
/* Apply I2c address patch to B1 */
2632-
if (!state->type_A && state->m_HiI2cPatch != NULL) {
2632+
if (!state->type_A && state->m_HiI2cPatch) {
26332633
status = WriteTable(state, state->m_HiI2cPatch);
26342634
if (status < 0)
26352635
break;

drivers/media/dvb-frontends/sp2.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,14 @@ static int sp2_exit(struct i2c_client *client)
357357

358358
dev_dbg(&client->dev, "\n");
359359

360-
if (client == NULL)
360+
if (!client)
361361
return 0;
362362

363363
s = i2c_get_clientdata(client);
364-
if (s == NULL)
364+
if (!s)
365365
return 0;
366366

367-
if (s->ca.data == NULL)
367+
if (!s->ca.data)
368368
return 0;
369369

370370
dvb_ca_en50221_release(&s->ca);

drivers/media/i2c/adv7604.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,7 +1948,7 @@ static int adv76xx_set_format(struct v4l2_subdev *sd,
19481948
return -EINVAL;
19491949

19501950
info = adv76xx_format_info(state, format->format.code);
1951-
if (info == NULL)
1951+
if (!info)
19521952
info = adv76xx_format_info(state, MEDIA_BUS_FMT_YUYV8_2X8);
19531953

19541954
adv76xx_fill_format(state, &format->format);
@@ -2256,7 +2256,7 @@ static int adv76xx_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
22562256
return 0;
22572257
}
22582258

2259-
if (data == NULL)
2259+
if (!data)
22602260
return -ENODATA;
22612261

22622262
if (edid->start_block >= state->edid.blocks)
@@ -3480,7 +3480,7 @@ static int adv76xx_probe(struct i2c_client *client,
34803480
state->i2c_clients[i] =
34813481
adv76xx_dummy_client(sd, state->pdata.i2c_addresses[i],
34823482
0xf2 + i);
3483-
if (state->i2c_clients[i] == NULL) {
3483+
if (!state->i2c_clients[i]) {
34843484
err = -ENOMEM;
34853485
v4l2_err(sd, "failed to create i2c client %u\n", i);
34863486
goto err_i2c;

drivers/media/pci/cx18/cx18-driver.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ static void request_module_async(struct work_struct *work)
255255
request_module("cx18-alsa");
256256

257257
/* Initialize cx18-alsa for this instance of the cx18 device */
258-
if (cx18_ext_init != NULL)
258+
if (cx18_ext_init)
259259
cx18_ext_init(dev);
260260
}
261261

@@ -291,11 +291,11 @@ int cx18_msleep_timeout(unsigned int msecs, int intr)
291291
/* Release ioremapped memory */
292292
static void cx18_iounmap(struct cx18 *cx)
293293
{
294-
if (cx == NULL)
294+
if (!cx)
295295
return;
296296

297297
/* Release io memory */
298-
if (cx->enc_mem != NULL) {
298+
if (cx->enc_mem) {
299299
CX18_DEBUG_INFO("releasing enc_mem\n");
300300
iounmap(cx->enc_mem);
301301
cx->enc_mem = NULL;
@@ -649,15 +649,15 @@ static void cx18_process_options(struct cx18 *cx)
649649
CX18_INFO("User specified %s card\n", cx->card->name);
650650
else if (cx->options.cardtype != 0)
651651
CX18_ERR("Unknown user specified type, trying to autodetect card\n");
652-
if (cx->card == NULL) {
652+
if (!cx->card) {
653653
if (cx->pci_dev->subsystem_vendor == CX18_PCI_ID_HAUPPAUGE) {
654654
cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT);
655655
CX18_INFO("Autodetected Hauppauge card\n");
656656
}
657657
}
658-
if (cx->card == NULL) {
658+
if (!cx->card) {
659659
for (i = 0; (cx->card = cx18_get_card(i)); i++) {
660-
if (cx->card->pci_list == NULL)
660+
if (!cx->card->pci_list)
661661
continue;
662662
for (j = 0; cx->card->pci_list[j].device; j++) {
663663
if (cx->pci_dev->device !=
@@ -676,7 +676,7 @@ static void cx18_process_options(struct cx18 *cx)
676676
}
677677
done:
678678

679-
if (cx->card == NULL) {
679+
if (!cx->card) {
680680
cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT);
681681
CX18_ERR("Unknown card: vendor/device: [%04x:%04x]\n",
682682
cx->pci_dev->vendor, cx->pci_dev->device);
@@ -698,7 +698,7 @@ static int cx18_create_in_workq(struct cx18 *cx)
698698
snprintf(cx->in_workq_name, sizeof(cx->in_workq_name), "%s-in",
699699
cx->v4l2_dev.name);
700700
cx->in_work_queue = alloc_ordered_workqueue("%s", 0, cx->in_workq_name);
701-
if (cx->in_work_queue == NULL) {
701+
if (!cx->in_work_queue) {
702702
CX18_ERR("Unable to create incoming mailbox handler thread\n");
703703
return -ENOMEM;
704704
}
@@ -1254,7 +1254,7 @@ static void cx18_cancel_out_work_orders(struct cx18 *cx)
12541254
{
12551255
int i;
12561256
for (i = 0; i < CX18_MAX_STREAMS; i++)
1257-
if (&cx->streams[i].video_dev != NULL)
1257+
if (&cx->streams[i].video_dev)
12581258
cancel_work_sync(&cx->streams[i].out_work_order);
12591259
}
12601260

@@ -1299,7 +1299,7 @@ static void cx18_remove(struct pci_dev *pci_dev)
12991299

13001300
pci_disable_device(cx->pci_dev);
13011301

1302-
if (cx->vbi.sliced_mpeg_data[0] != NULL)
1302+
if (cx->vbi.sliced_mpeg_data[0])
13031303
for (i = 0; i < CX18_VBI_FRAMES; i++)
13041304
kfree(cx->vbi.sliced_mpeg_data[i]);
13051305

drivers/media/pci/mantis/hopper_cards.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static irqreturn_t hopper_irq_handler(int irq, void *dev_id)
7272
struct mantis_ca *ca;
7373

7474
mantis = (struct mantis_pci *) dev_id;
75-
if (unlikely(mantis == NULL)) {
75+
if (unlikely(!mantis)) {
7676
dprintk(MANTIS_ERROR, 1, "Mantis == NULL");
7777
return IRQ_NONE;
7878
}
@@ -164,7 +164,7 @@ static int hopper_pci_probe(struct pci_dev *pdev,
164164
int err = 0;
165165

166166
mantis = kzalloc(sizeof(*mantis), GFP_KERNEL);
167-
if (mantis == NULL) {
167+
if (!mantis) {
168168
err = -ENOMEM;
169169
goto fail0;
170170
}

drivers/media/platform/atmel/atmel-isc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,7 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier)
15901590
spin_lock_init(&isc->dma_queue_lock);
15911591

15921592
sd_entity->config = v4l2_subdev_alloc_pad_config(sd_entity->sd);
1593-
if (sd_entity->config == NULL)
1593+
if (!sd_entity->config)
15941594
return -ENOMEM;
15951595

15961596
ret = isc_formats_init(isc);
@@ -1714,15 +1714,15 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)
17141714

17151715
subdev_entity = devm_kzalloc(dev,
17161716
sizeof(*subdev_entity), GFP_KERNEL);
1717-
if (subdev_entity == NULL) {
1717+
if (!subdev_entity) {
17181718
of_node_put(rem);
17191719
ret = -ENOMEM;
17201720
break;
17211721
}
17221722

17231723
subdev_entity->asd = devm_kzalloc(dev,
17241724
sizeof(*subdev_entity->asd), GFP_KERNEL);
1725-
if (subdev_entity->asd == NULL) {
1725+
if (!subdev_entity->asd) {
17261726
of_node_put(rem);
17271727
ret = -ENOMEM;
17281728
break;

drivers/media/platform/atmel/atmel-isi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ static void buffer_queue(struct vb2_buffer *vb)
411411
spin_lock_irqsave(&isi->irqlock, flags);
412412
list_add_tail(&buf->list, &isi->video_buffer_list);
413413

414-
if (isi->active == NULL) {
414+
if (!isi->active) {
415415
isi->active = buf;
416416
if (vb2_is_streaming(vb->vb2_queue))
417417
start_dma(isi, buf);
@@ -1141,7 +1141,7 @@ static int isi_graph_init(struct atmel_isi *isi)
11411141

11421142
/* Register the subdevices notifier. */
11431143
subdevs = devm_kzalloc(isi->dev, sizeof(*subdevs), GFP_KERNEL);
1144-
if (subdevs == NULL) {
1144+
if (!subdevs) {
11451145
of_node_put(isi->entity.node);
11461146
return -ENOMEM;
11471147
}
@@ -1200,7 +1200,7 @@ static int atmel_isi_probe(struct platform_device *pdev)
12001200
return ret;
12011201

12021202
isi->vdev = video_device_alloc();
1203-
if (isi->vdev == NULL) {
1203+
if (!isi->vdev) {
12041204
ret = -ENOMEM;
12051205
goto err_vdev_alloc;
12061206
}

drivers/media/usb/zr364xx/zr364xx.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,9 @@ static int buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
385385
vb);
386386
int rc;
387387

388-
DBG("%s, field=%d, fmt name = %s\n", __func__, field, cam->fmt != NULL ?
389-
cam->fmt->name : "");
390-
if (cam->fmt == NULL)
388+
DBG("%s, field=%d, fmt name = %s\n", __func__, field,
389+
cam->fmt ? cam->fmt->name : "");
390+
if (!cam->fmt)
391391
return -EINVAL;
392392

393393
buf->vb.size = cam->width * cam->height * (cam->fmt->depth >> 3);
@@ -787,7 +787,7 @@ static int zr364xx_vidioc_try_fmt_vid_cap(struct file *file, void *priv,
787787
struct zr364xx_camera *cam = video_drvdata(file);
788788
char pixelformat_name[5];
789789

790-
if (cam == NULL)
790+
if (!cam)
791791
return -ENODEV;
792792

793793
if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_JPEG) {
@@ -817,7 +817,7 @@ static int zr364xx_vidioc_g_fmt_vid_cap(struct file *file, void *priv,
817817
{
818818
struct zr364xx_camera *cam;
819819

820-
if (file == NULL)
820+
if (!file)
821821
return -ENODEV;
822822
cam = video_drvdata(file);
823823

@@ -979,13 +979,13 @@ static void read_pipe_completion(struct urb *purb)
979979

980980
pipe_info = purb->context;
981981
_DBG("%s %p, status %d\n", __func__, purb, purb->status);
982-
if (pipe_info == NULL) {
982+
if (!pipe_info) {
983983
printk(KERN_ERR KBUILD_MODNAME ": no context!\n");
984984
return;
985985
}
986986

987987
cam = pipe_info->cam;
988-
if (cam == NULL) {
988+
if (!cam) {
989989
printk(KERN_ERR KBUILD_MODNAME ": no context!\n");
990990
return;
991991
}
@@ -1069,7 +1069,7 @@ static void zr364xx_stop_readpipe(struct zr364xx_camera *cam)
10691069
{
10701070
struct zr364xx_pipeinfo *pipe_info;
10711071

1072-
if (cam == NULL) {
1072+
if (!cam) {
10731073
printk(KERN_ERR KBUILD_MODNAME ": invalid device\n");
10741074
return;
10751075
}
@@ -1273,7 +1273,7 @@ static int zr364xx_mmap(struct file *file, struct vm_area_struct *vma)
12731273
struct zr364xx_camera *cam = video_drvdata(file);
12741274
int ret;
12751275

1276-
if (cam == NULL) {
1276+
if (!cam) {
12771277
DBG("%s: cam == NULL\n", __func__);
12781278
return -ENODEV;
12791279
}
@@ -1357,7 +1357,7 @@ static int zr364xx_board_init(struct zr364xx_camera *cam)
13571357

13581358
pipe->transfer_buffer = kzalloc(pipe->transfer_size,
13591359
GFP_KERNEL);
1360-
if (pipe->transfer_buffer == NULL) {
1360+
if (!pipe->transfer_buffer) {
13611361
DBG("out of memory!\n");
13621362
return -ENOMEM;
13631363
}
@@ -1373,7 +1373,7 @@ static int zr364xx_board_init(struct zr364xx_camera *cam)
13731373
DBG("valloc %p, idx %lu, pdata %p\n",
13741374
&cam->buffer.frame[i], i,
13751375
cam->buffer.frame[i].lpvbits);
1376-
if (cam->buffer.frame[i].lpvbits == NULL) {
1376+
if (!cam->buffer.frame[i].lpvbits) {
13771377
printk(KERN_INFO KBUILD_MODNAME ": out of memory. Using less frames\n");
13781378
break;
13791379
}

0 commit comments

Comments
 (0)