btrfs-progs/common/tree-search.h
David Sterba ed89c67132 btrfs-progs: fix struct btrfs_tree_search_args layout
Clang 19 reports:

In file included from common/fsfeatures.c:34:
  ./common/tree-search.h:11:2: warning: field '' with variable sized type
  'union btrfs_tree_search_args::(anonymous at
  ./common/tree-search.h:11:2)' not at the end of a struct or class is a
  GNU extension [-Wgnu-variable-sized-type-not-at-end]

which is correct. This does not still fix the problem with tree search
v2, disabled in d73e698248 ("btrfs-progs: temporarily disable usage
of v2 of search tree ioctl").

Signed-off-by: David Sterba <dsterba@suse.com>
2025-01-17 22:30:40 +01:00

35 lines
887 B
C

#ifndef __COMMON_TREE_SEARCH_H__
#define __COMMON_TREE_SEARCH_H__
#include "kerncompat.h"
#include <stdbool.h>
#include "kernel-shared/uapi/btrfs.h"
#define BTRFS_TREE_SEARCH_V2_BUF_SIZE 65536
struct btrfs_tree_search_args {
bool use_v2;
union {
struct btrfs_ioctl_search_args args1;
struct btrfs_ioctl_search_args_v2 args2;
u8 filler[sizeof(struct btrfs_ioctl_search_args_v2) +
BTRFS_TREE_SEARCH_V2_BUF_SIZE];
};
};
int btrfs_tree_search_ioctl(int fd, struct btrfs_tree_search_args *sa);
static inline struct btrfs_ioctl_search_key *btrfs_tree_search_sk(struct btrfs_tree_search_args *sa)
{
/* Same offset for v1 and v2. */
return &sa->args1.key;
}
static inline void *btrfs_tree_search_data(struct btrfs_tree_search_args *sa, unsigned long offset) {
if (sa->use_v2)
return (void *)(sa->args2.buf + offset);
return (void *)(sa->args1.buf + offset);
}
#endif