All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Oliver Hartkopp <socketcan@hartkopp.net>, linux-can@vger.kernel.org
Cc: kernel@pengutronix.de
Subject: Re: [PATCH 02/14] can: give structs holding the CAN statistics a sensible name
Date: Fri, 25 Aug 2017 15:08:17 +0200	[thread overview]
Message-ID: <361c5e96-0e89-ba24-4fbf-18087470bc69@pengutronix.de> (raw)
In-Reply-To: <92a0dacc-e1d2-435e-2bee-0ff0a20a655e@hartkopp.net>


[-- Attachment #1.1: Type: text/plain, Size: 2777 bytes --]

On 08/24/2017 02:58 PM, Oliver Hartkopp wrote:
> Naming structs and its instances identically is bad.
> 
> On 08/02/2017 07:44 PM, Marc Kleine-Budde wrote:
> 
>>   struct netns_can {
>>   #if IS_ENABLED(CONFIG_PROC_FS)
>> @@ -30,8 +30,8 @@ struct netns_can {
>>   	struct dev_rcv_lists *can_rx_alldev_list;
>>   	spinlock_t can_rcvlists_lock;
>>   	struct timer_list can_stattimer;/* timer for statistics update */
>> -	struct s_stats *can_stats;	/* packet statistics */
>> -	struct s_pstats *can_pstats;	/* receive list statistics */
>> +	struct can_stats *can_stats; /* packet statistics */
>> +	struct can_pstats *can_pstats; /* receive list statistics */
                               ^
Now I found out what that "p" originally means:

> /* persistent statistics */
> struct can_pstats {
> 	unsigned long stats_reset;
> 	unsigned long user_reset;
> 	unsigned long rcv_entries;
> 	unsigned long rcv_entries_max;
> };

\o/

> If you really want to rename this stuff, what about this:
> 
> struct can_pkt_stats *can_stats; /* packet statistics */
> struct can_rxl_stats *can_rstats; /* receive list statistics */
             ^^^
We're using rcv_list(s) instead of rxl in various other places.

If we give the variables speaking names, the comments are obsolete:

struct can_pkg_stats *can_pkg_stats;
struct can_rcv_list_stats *can_rcv_list_stats;

We can remove the "can_" prefix of the variables in the struct
netns_can, as the struct already has the "can" in it.

So the struct becomes:

> struct netns_can {
> #if IS_ENABLED(CONFIG_PROC_FS)
> 	struct proc_dir_entry *proc_dir;
> 	struct proc_dir_entry *pde_version;
> 	struct proc_dir_entry *pde_stats;
> 	struct proc_dir_entry *pde_reset_stats;
> 	struct proc_dir_entry *pde_rcvlist_all;
> 	struct proc_dir_entry *pde_rcvlist_fil;
> 	struct proc_dir_entry *pde_rcvlist_inv;
> 	struct proc_dir_entry *pde_rcvlist_sff;
> 	struct proc_dir_entry *pde_rcvlist_eff;
> 	struct proc_dir_entry *pde_rcvlist_err;
> 	struct proc_dir_entry *bcmproc_dir;
> #endif
> 
> 	/* receive filters subscribed for 'all' CAN devices */
> 	struct can_dev_rcv_lists *rx_alldev_list;
> 	spinlock_t rcvlists_lock;
> 	struct timer_list stattimer; /* timer for statistics update */
> 	struct can_pkg_stats *pkg_stats;
> 	struct can_rcv_lists_stats *rcv_lists_stats;
> 
> #if IS_ENABLED(CONFIG_CAN_GW)
> 	/* CAN GW per-net gateway jobs */
> 	struct hlist_head cgw_list;
> #endif
> };

regards,
Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2017-08-25 13:08 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-02 17:44 [00/14] can: cleanup of af_can/raw + simplifying of ndev->ml_priv handling Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 01/14] can: af_can: can_pernet_init(): add missing error handling for kzalloc returning NULL Marc Kleine-Budde
2017-08-24 12:42   ` Oliver Hartkopp
2017-08-25  8:31     ` Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 02/14] can: give structs holding the CAN statistics a sensible name Marc Kleine-Budde
2017-08-24 12:58   ` Oliver Hartkopp
2017-08-25 13:08     ` Marc Kleine-Budde [this message]
2017-08-25 17:32       ` Oliver Hartkopp
2017-08-28  7:25         ` Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 03/14] can: af_can: give struct holding the CAN per device receive lists " Marc Kleine-Budde
2017-08-24 12:59   ` Oliver Hartkopp
2017-08-28 10:58     ` Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 04/14] can: af_can: give variable " Marc Kleine-Budde
2017-08-24 13:03   ` Oliver Hartkopp
2017-08-28 13:39     ` Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 05/14] can: proc: " Marc Kleine-Budde
2017-08-24 13:05   ` Oliver Hartkopp
2017-08-02 17:44 ` [PATCH 06/14] can: af_can: rename find_rcv_list() to can_rcv_list_find() Marc Kleine-Budde
2017-08-24 13:11   ` Oliver Hartkopp
2017-08-28 11:53     ` Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 07/14] can: af_can: give variable holding the CAN receiver and the receiver list a sensible name Marc Kleine-Budde
2017-08-24 13:27   ` Oliver Hartkopp
2017-08-28 15:24     ` Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 08/14] can: af_can: can_rx_register(): use max() instead of open coding it Marc Kleine-Budde
2017-08-24 13:28   ` Oliver Hartkopp
2017-08-28 15:24     ` Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 09/14] can: raw: use struct sock::sk_bound_dev_if instead of struct raw_sock::ifindex Marc Kleine-Budde
2017-08-24 13:39   ` Oliver Hartkopp
2017-08-24 14:11     ` Kurt Van Dijck
2017-08-25  8:43       ` Oliver Hartkopp
2017-08-25  9:34         ` Kurt Van Dijck
2017-08-25 17:54           ` Oliver Hartkopp
2017-08-25 18:46             ` Kurt Van Dijck
2017-08-27 14:27               ` Oliver Hartkopp
2017-08-02 17:44 ` [PATCH 10/14] can: raw: raw_bind: bail out if can_family is not AF_CAN Marc Kleine-Budde
2017-08-24 13:40   ` Oliver Hartkopp
2017-08-28 15:25     ` Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 11/14] can: af_can: can_pernet_exit(): no need to iterate over and cleanup registered CAN devices Marc Kleine-Budde
2017-08-24 13:48   ` Oliver Hartkopp
2017-08-02 17:44 ` [PATCH 12/14] can: introduce CAN midlayer private and allocate it automatically Marc Kleine-Budde
2017-08-24 13:51   ` Oliver Hartkopp
2017-08-02 17:44 ` [PATCH 13/14] can: make use of preallocated can_ml_priv for per device struct can_dev_rcv_lists Marc Kleine-Budde
2017-08-24 13:55   ` Oliver Hartkopp
2017-08-02 17:44 ` [PATCH 14/14] can: af_can: remove NULL-ptr checks from users of can_dev_rcv_lists_find() Marc Kleine-Budde
2017-08-24 13:58   ` Oliver Hartkopp
2017-08-03  5:03 ` [00/14] can: cleanup of af_can/raw + simplifying of ndev->ml_priv handling Oliver Hartkopp
2017-08-03  7:39   ` Marc Kleine-Budde
2017-08-17 11:57   ` Marc Kleine-Budde
2017-08-17 12:57     ` Oliver Hartkopp
2017-08-17 13:02       ` Marc Kleine-Budde
2017-08-17 13:03         ` Marc Kleine-Budde
2017-08-17 13:06           ` Marc Kleine-Budde
2017-08-17 13:13             ` Oliver Hartkopp
2017-08-17 13:17               ` Marc Kleine-Budde
2017-08-17 13:54                 ` Oliver Hartkopp
2017-08-17 14:08                   ` Marc Kleine-Budde
2017-08-24 12:31                     ` Oliver Hartkopp
2017-08-17 13:08         ` Oliver Hartkopp

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=361c5e96-0e89-ba24-4fbf-18087470bc69@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=kernel@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=socketcan@hartkopp.net \
    /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.