From: Dan Carpenter <dan.carpenter@oracle.com>
To: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Cc: David Sterba <dsterba@suse.cz>,
Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>,
linux-kernel@vger.kernel.org
Subject: Re: [patch v2] checkpatch: complain about GW-BASIC style label names
Date: Thu, 4 Jun 2015 13:46:10 +0300 [thread overview]
Message-ID: <20150604104610.GD28762@mwanda> (raw)
In-Reply-To: <20150513144937.67e7e383@lxorguk.ukuu.org.uk>
It's weird that you would defend GW-BASIC label names because you
wouldn't defend code which does:
int var1, var2, var4;
Naming labels is useful.
goto error9;
goto err_cleanup_sysfs1;
The second one is more clear. But it's better to look at it in context:
drivers/hid/hid-picolcd_core.c
584 error = device_create_file(&hdev->dev, &dev_attr_operation_mode_delay);
585 if (error) {
586 hid_err(hdev, "failed to create sysfs attributes\n");
587 goto err_cleanup_hid_ll;
588 }
589
590 error = device_create_file(&hdev->dev, &dev_attr_operation_mode);
591 if (error) {
592 hid_err(hdev, "failed to create sysfs attributes\n");
593 goto err_cleanup_sysfs1;
594 }
Without scrolling down, you already know that the error handling is
going to uncreate the dev_attr_operation_mode_delay files so it's
correct.
drivers/infiniband/core/mad.c
2977 snprintf(name, sizeof name, "ib_mad%d", port_num);
2978 port_priv->wq = create_singlethread_workqueue(name);
2979 if (!port_priv->wq) {
2980 ret = -ENOMEM;
2981 goto error8;
2982 }
2983 INIT_WORK(&port_priv->work, ib_mad_completion_handler);
2984
2985 spin_lock_irqsave(&ib_mad_port_list_lock, flags);
2986 list_add_tail(&port_priv->port_list, &ib_mad_port_list);
2987 spin_unlock_irqrestore(&ib_mad_port_list_lock, flags);
2988
2989 ret = ib_mad_port_start(port_priv);
2990 if (ret) {
2991 dev_err(&device->dev, "Couldn't start port\n");
2992 goto error9;
2993 }
Hopefully, it undoes the list_add_tail() but the error9 isn't clear.
Here are the labels:
drivers/infiniband/core/mad.c
2995 return 0;
2996
2997 error9:
2998 spin_lock_irqsave(&ib_mad_port_list_lock, flags);
2999 list_del_init(&port_priv->port_list);
3000 spin_unlock_irqrestore(&ib_mad_port_list_lock, flags);
3001
3002 destroy_workqueue(port_priv->wq);
3003 error8:
3004 destroy_mad_qp(&port_priv->qp_info[1]);
3005 error7:
3006 destroy_mad_qp(&port_priv->qp_info[0]);
3007 error6:
3008 ib_dereg_mr(port_priv->mr);
3009 error5:
3010 ib_dealloc_pd(port_priv->pd);
3011 error4:
3012 ib_destroy_cq(port_priv->cq);
3013 cleanup_recv_queue(&port_priv->qp_info[1]);
3014 cleanup_recv_queue(&port_priv->qp_info[0]);
3015 error3:
3016 kfree(port_priv);
3017
3018 return ret;
3019 }
So ok, it is correct. But does error8 do what was intended? You can't
tell without scrolling back. Also this is the first example which I
chose at random but it makes me happy that error2 and error1 are
missing.
Here is the labels with meaningful names:
drivers/hid/hid-picolcd_core.c
606 err_cleanup_sysfs2:
607 device_remove_file(&hdev->dev, &dev_attr_operation_mode);
608 err_cleanup_sysfs1:
609 device_remove_file(&hdev->dev, &dev_attr_operation_mode_delay);
610 err_cleanup_hid_ll:
611 hid_hw_close(hdev);
612 err_cleanup_hid_hw:
613 hid_hw_stop(hdev);
614 err_cleanup_data:
615 kfree(data);
616 err_no_cleanup:
617 hid_set_drvdata(hdev, NULL);
618
619 return error;
620 }
It's not clear to me what "hid_ll" means, also "no_cleanup" seems a bit
misleading, but the rest is pretty straight forward just by looking at
it.
regards,
dan carpenter
next prev parent reply other threads:[~2015-06-04 10:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-07 11:21 [patch] checkpatch: complain about GW-BASIC style label names Dan Carpenter
2015-05-07 13:47 ` Joe Perches
2015-05-07 19:42 ` Dan Carpenter
2015-05-07 20:17 ` Joe Perches
2015-05-07 20:35 ` Joe Perches
2015-05-13 12:37 ` [patch v2] " Dan Carpenter
2015-05-13 13:16 ` David Sterba
2015-05-13 13:47 ` Dan Carpenter
2015-05-13 13:49 ` One Thousand Gnomes
2015-06-04 10:46 ` Dan Carpenter [this message]
2015-05-13 14:12 ` Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150604104610.GD28762@mwanda \
--to=dan.carpenter@oracle.com \
--cc=apw@canonical.com \
--cc=dsterba@suse.cz \
--cc=gnomes@lxorguk.ukuu.org.uk \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.