/* Check if we really need to use newuidmap and newgidmap.
* If the user is only remapping their own {g,u}id, we don't need it.
*/
- if (use_shadow && list_len(idmap) == 2) {
+ if (use_shadow && list_len(map, idmap, head) == 2) {
use_shadow = false;
list_for_each_entry(map, idmap, head) {
if (map->idtype == ID_TYPE_UID && map->range == 1 &&
else
memset(retv, 0, inlen);
- listlen = list_len(&c->id_map);
+ listlen = list_len(map, &c->id_map, head);
list_for_each_entry(map, &c->id_map, head) {
ret = strnprintf(buf, sizeof(buf), "%c %lu %lu %lu",
(map->idtype == ID_TYPE_UID) ? 'u' : 'g',
else
memset(retv, 0, inlen);
- listlen = list_len(&netdev->ipv4_addresses);
+ listlen = list_len(inetdev, &netdev->ipv4_addresses, head);
list_for_each_entry(inetdev, &netdev->ipv4_addresses, head) {
if (!inet_ntop(AF_INET, &inetdev->addr, buf, sizeof(buf)))
else
memset(retv, 0, inlen);
- listlen = list_len(&netdev->priv.veth_attr.ipv4_routes);
+ listlen = list_len(inetdev, &netdev->priv.veth_attr.ipv4_routes, head);
list_for_each_entry(inetdev, &netdev->priv.veth_attr.ipv4_routes, head) {
if (!inet_ntop(AF_INET, &inetdev->addr, buf, sizeof(buf)))
return -errno;
else
memset(retv, 0, inlen);
- listlen = list_len(&netdev->ipv6_addresses);
+ listlen = list_len(inet6dev, &netdev->ipv6_addresses, head);
list_for_each_entry(inet6dev, &netdev->ipv6_addresses, head) {
if (!inet_ntop(AF_INET6, &inet6dev->addr, buf, sizeof(buf)))
return -errno;
else
memset(retv, 0, inlen);
- listlen = list_len(&netdev->priv.veth_attr.ipv6_routes);
+ listlen = list_len(inet6dev, &netdev->priv.veth_attr.ipv6_routes, head);
list_for_each_entry(inet6dev, &netdev->priv.veth_attr.ipv6_routes, head) {
if (!inet_ntop(AF_INET6, &inet6dev->addr, buf, sizeof(buf)))
return -errno;
int static_args = 23, ret;
int netnr = 0;
struct mntent mntent;
+ struct lxc_netdev *netdev;
+ struct string_entry *strentry;
char buf[4096], ttys[32];
if (ttys[0])
static_args += 2;
- static_args += list_len(&opts->c->lxc_conf->netdevs) * 2;
+ static_args += list_len(netdev, &opts->c->lxc_conf->netdevs, head) * 2;
} else {
return log_error_errno(-EINVAL, EINVAL, "Invalid criu operation specified");
}
if (opts->user->action_script)
static_args += 2;
- static_args += 2 * list_len(&opts->c->lxc_conf->mount_entries);
+ static_args += 2 * list_len(strentry, &opts->c->lxc_conf->mount_entries, head);
ret = strnprintf(log, sizeof(log), "%s/%s.log", opts->user->directory, opts->action);
if (ret < 0)
DECLARE_ARG("--leave-running");
} else if (strequal(opts->action, "restore")) {
struct lxc_conf *lxc_conf = opts->c->lxc_conf;
- struct lxc_netdev *netdev;
DECLARE_ARG("--root");
DECLARE_ARG(opts->c->lxc_conf->rootfs.mount);
pos && ({ n = pos->member.next; 1; }); \
pos = hlist_entry_safe(n, typeof(*pos), member))
-static inline size_t list_len(struct list_head *list)
-{
- size_t i = 0;
-
- list_for_each(list, list) {
- i++;
- }
-
- return i;
-}
+#define list_len(pos, head, member) \
+ ({ \
+ size_t __list_len__ = 0; \
+ \
+ list_for_each_entry(pos, head, member) { \
+ (__list_len__)++; \
+ } \
+ \
+ __list_len__; \
+ })
#endif /* __LXC_HLIST_H */