Re: [PATCH iproute2-next 1/2] ss: introduce cgroup2 cache and helper functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



global comment. iproute2 uses the net coding style of reverse xmas tree
for declarations. There are a number of places that need to be fixed up.

On 4/30/20 9:52 AM, Dmitry Yakunin wrote:
> diff --git a/lib/cg_map.c b/lib/cg_map.c
> new file mode 100644
> index 0000000..0a1d834
> --- /dev/null
> +++ b/lib/cg_map.c
> @@ -0,0 +1,133 @@
> +/*
> + * cg_map.c	cgroup v2 cache
> + *
> + *		This program is free software; you can redistribute it and/or
> + *		modify it under the terms of the GNU General Public License
> + *		as published by the Free Software Foundation; either version
> + *		2 of the License, or (at your option) any later version.

Drop the boilerplate in favor of SPDX line

> + *
> + * Authors:	Dmitry Yakunin <zeil@xxxxxxxxxxxxxx>
> + */
> +
> +#include <stdlib.h>
> +#include <string.h>
> +#include <stdio.h>
> +#include <stdbool.h>
> +#include <linux/types.h>
> +#include <linux/limits.h>
> +#include <ftw.h>
> +
> +#include "cg_map.h"
> +#include "list.h"
> +#include "utils.h"
> +
> +struct cg_cache {
> +	struct hlist_node id_hash;
> +	__u64	id;
> +	char	path[];
> +};
> +
> +#define IDMAP_SIZE	1024
> +static struct hlist_head id_head[IDMAP_SIZE];
> +
> +static struct cg_cache *cg_get_by_id(__u64 id)
> +{
> +	struct hlist_node *n;
> +	unsigned int h = id & (IDMAP_SIZE - 1);
> +
> +	hlist_for_each(n, &id_head[h]) {
> +		struct cg_cache *cg
> +			= container_of(n, struct cg_cache, id_hash);

Don't split the line like that. Since you need 2 lines just do:
+		struct cg_cache *cg;
+
+		cg = container_of(n, struct cg_cache, id_hash);

> +		if (cg->id == id)
> +			return cg;
> +	}
> +
> +	return NULL;
> +}
> +







[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux