Skip to content

Commit

Permalink
Use flexible array members (#3411)
Browse files Browse the repository at this point in the history
* Use flexible array members

for dynamically sized trailing elements in a structure. See [here](https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays) for more information on this.

Closes: #3366

Signed-off-by: black-dragon74 <niryadav@redhat.com>

* [dht] Remove unused `dht_disk_layout` structure

Note: This code was a part of initial DHT commit (5dc7cbf),
a bit of history there :)

Signed-off-by: black-dragon74 <niryadav@redhat.com>
  • Loading branch information
black-dragon74 authored Apr 28, 2022
1 parent 0a22c47 commit 1cfff6e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
4 changes: 2 additions & 2 deletions libglusterfs/src/glusterfs/mem-pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct mem_acct_rec {
struct mem_acct {
uint32_t num_types;
gf_atomic_t refcnt;
struct mem_acct_rec rec[0];
struct mem_acct_rec rec[];
};

struct mem_header {
Expand Down Expand Up @@ -297,7 +297,7 @@ typedef struct per_thread_pool_list {
* in the implementation code so we just make it a single-element array
* here.
*/
per_thread_pool_t pools[1];
per_thread_pool_t pools[];
} per_thread_pool_list_t;

/* actual pool structure, shared between different mem_pools */
Expand Down
10 changes: 0 additions & 10 deletions xlators/cluster/dht/src/dht-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -629,16 +629,6 @@ struct dht_dfoffset_ctx {
};
typedef struct dht_dfoffset_ctx dht_dfoffset_ctx_t;

struct dht_disk_layout {
uint32_t cnt;
uint32_t type;
struct {
uint32_t start;
uint32_t stop;
} list[1];
};
typedef struct dht_disk_layout dht_disk_layout_t;

typedef enum {
GF_DHT_MIGRATE_DATA,
GF_DHT_MIGRATE_DATA_EVEN_IF_LINK_EXISTS,
Expand Down
2 changes: 1 addition & 1 deletion xlators/features/changelog/lib/src/gf-changelog-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct gf_event {

struct list_head list;

struct iovec iov[0];
struct iovec iov[];
};
#define GF_EVENT_CALLOC_SIZE(cnt, len) \
(sizeof(struct gf_event) + (cnt * sizeof(struct iovec)) + len)
Expand Down

0 comments on commit 1cfff6e

Please sign in to comment.