Skip to content

Commit 7a11717

Browse files
committed
cleanup: rename _cleanup_free_ to __cleanup_free
Follow the new naming pattern of the compiler attributes which is just __NAME. This is what the kernel is using as well. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 7adfa53 commit 7a11717

28 files changed

Lines changed: 240 additions & 240 deletions

fabrics.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,8 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect)
587587

588588
int fabrics_connect(const char *desc, int argc, char **argv)
589589
{
590-
_cleanup_free_ char *hnqn = NULL;
591-
_cleanup_free_ char *hid = NULL;
590+
__cleanup_free char *hnqn = NULL;
591+
__cleanup_free char *hid = NULL;
592592
char *config_file = NULL;
593593
char *context = NULL;
594594
_cleanup_nvme_global_ctx_ struct libnvme_global_ctx *ctx = NULL;

libnvme/src/nvme/cleanup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static inline void freep(void *p)
2929
{
3030
free(*(void **)p);
3131
}
32-
#define _cleanup_free_ __cleanup(freep)
32+
#define __cleanup_free __cleanup(freep)
3333

3434
static inline DEFINE_CLEANUP_FUNC(cleanup_file, FILE *, fclose)
3535
#define _cleanup_file_ __cleanup(cleanup_file)

libnvme/src/nvme/cmds.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ __public int libnvme_get_uuid_list(struct libnvme_transport_handle *hdl,
313313
__public int libnvme_get_telemetry_max(struct libnvme_transport_handle *hdl,
314314
enum nvme_telemetry_da *da, size_t *data_tx)
315315
{
316-
_cleanup_free_ struct nvme_id_ctrl *id_ctrl = NULL;
316+
__cleanup_free struct nvme_id_ctrl *id_ctrl = NULL;
317317
struct libnvme_passthru_cmd cmd;
318318
int err;
319319

@@ -354,7 +354,7 @@ __public int libnvme_get_telemetry_log(struct libnvme_transport_handle *hdl, boo
354354
static const __u32 xfer = NVME_LOG_TELEM_BLOCK_SIZE;
355355
struct nvme_telemetry_log *telem;
356356
struct libnvme_passthru_cmd cmd;
357-
_cleanup_free_ void *log = NULL;
357+
__cleanup_free void *log = NULL;
358358
void *tmp;
359359
int err;
360360
size_t dalb;
@@ -477,7 +477,7 @@ __public int libnvme_get_new_host_telemetry(struct libnvme_transport_handle *hdl
477477
int libnvme_get_lba_status_log(struct libnvme_transport_handle *hdl, bool rae,
478478
struct nvme_lba_status_log **log)
479479
{
480-
_cleanup_free_ struct nvme_lba_status_log *buf = NULL;
480+
__cleanup_free struct nvme_lba_status_log *buf = NULL;
481481
struct libnvme_passthru_cmd cmd;
482482
__u32 size;
483483
void *tmp;
@@ -532,7 +532,7 @@ __public size_t libnvme_get_ana_log_len_from_id_ctrl(const struct nvme_id_ctrl *
532532

533533
__public int libnvme_get_ana_log_len(struct libnvme_transport_handle *hdl, size_t *analen)
534534
{
535-
_cleanup_free_ struct nvme_id_ctrl *ctrl = NULL;
535+
__cleanup_free struct nvme_id_ctrl *ctrl = NULL;
536536
struct libnvme_passthru_cmd cmd;
537537
int ret;
538538

@@ -552,7 +552,7 @@ __public int libnvme_get_ana_log_len(struct libnvme_transport_handle *hdl, size_
552552
__public int libnvme_get_logical_block_size(struct libnvme_transport_handle *hdl,
553553
__u32 nsid, int *blksize)
554554
{
555-
_cleanup_free_ struct nvme_id_ns *ns = NULL;
555+
__cleanup_free struct nvme_id_ns *ns = NULL;
556556
struct libnvme_passthru_cmd cmd;
557557
__u8 flbas;
558558
int ret;

libnvme/src/nvme/fabrics.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ __public int libnvmf_context_set_crypto(struct libnvmf_context *fctx,
316316
return 0;
317317

318318
if (!strncmp(tls_key, "pin:", 4)) {
319-
_cleanup_free_ unsigned char *raw_secret = NULL;
320-
_cleanup_free_ char *encoded_key = NULL;
319+
__cleanup_free unsigned char *raw_secret = NULL;
320+
__cleanup_free char *encoded_key = NULL;
321321
int key_len = 32;
322322

323323
err = libnvme_create_raw_secret(fctx->ctx, tls_key,
@@ -629,7 +629,7 @@ static int inet6_pton(struct libnvme_global_ctx *ctx, const char *src, uint16_t
629629
if (strlen(src) > INET6_ADDRSTRLEN)
630630
return -EINVAL;
631631

632-
_cleanup_free_ char *tmp = strdup(src);
632+
__cleanup_free char *tmp = strdup(src);
633633
if (!tmp) {
634634
libnvme_msg(ctx, LOG_ERR, "cannot copy: %s\n", src);
635635
return -ENOMEM;
@@ -1039,7 +1039,7 @@ __public int libnvmf_add_ctrl(libnvme_host_t h, libnvme_ctrl_t c,
10391039
{
10401040
libnvme_subsystem_t s;
10411041
const char *root_app, *app;
1042-
_cleanup_free_ char *argstr = NULL;
1042+
__cleanup_free char *argstr = NULL;
10431043
int ret;
10441044

10451045
/* highest prio have configs from command line */
@@ -1132,7 +1132,7 @@ __public int libnvmf_add_ctrl(libnvme_host_t h, libnvme_ctrl_t c,
11321132

11331133
__public int libnvmf_connect_ctrl(libnvme_ctrl_t c)
11341134
{
1135-
_cleanup_free_ char *argstr = NULL;
1135+
__cleanup_free char *argstr = NULL;
11361136
int ret;
11371137

11381138
ret = build_options(c->s->h, c, &argstr);
@@ -1578,7 +1578,7 @@ static int nvmf_dim(libnvme_ctrl_t c, enum nvmf_dim_tas tas, __u8 trtype,
15781578
__u32 *result)
15791579
{
15801580
struct libnvme_global_ctx *ctx = c->s && c->s->h ? c->s->h->ctx : NULL;
1581-
_cleanup_free_ struct nvmf_dim_data *dim = NULL;
1581+
__cleanup_free struct nvmf_dim_data *dim = NULL;
15821582
struct libnvme_transport_handle *hdl = libnvme_ctrl_get_transport_handle(c);
15831583
struct libnvme_passthru_cmd cmd;
15841584
struct nvmf_ext_die *die;
@@ -1709,7 +1709,7 @@ static const char *dctype_str[] = {
17091709
*/
17101710
static int nvme_fetch_cntrltype_dctype_from_id(libnvme_ctrl_t c)
17111711
{
1712-
_cleanup_free_ struct nvme_id_ctrl *id = NULL;
1712+
__cleanup_free struct nvme_id_ctrl *id = NULL;
17131713
int ret;
17141714

17151715
id = __libnvme_alloc(sizeof(*id));
@@ -1789,10 +1789,10 @@ static char *unescape_uri(const char *str, int len)
17891789
__public int libnvme_parse_uri(const char *str, struct libnvme_fabrics_uri **urip)
17901790
{
17911791
struct libnvme_fabrics_uri *uri;
1792-
_cleanup_free_ char *scheme = NULL;
1793-
_cleanup_free_ char *authority = NULL;
1794-
_cleanup_free_ char *path = NULL;
1795-
_cleanup_free_ char *h = NULL;
1792+
__cleanup_free char *scheme = NULL;
1793+
__cleanup_free char *authority = NULL;
1794+
__cleanup_free char *path = NULL;
1795+
__cleanup_free char *h = NULL;
17961796
const char *host;
17971797
int i;
17981798

@@ -1918,8 +1918,8 @@ static libnvme_ctrl_t lookup_ctrl(libnvme_host_t h, struct libnvmf_context *fctx
19181918
static int lookup_host(struct libnvme_global_ctx *ctx,
19191919
struct libnvmf_context *fctx, struct libnvme_host **host)
19201920
{
1921-
_cleanup_free_ char *hnqn = NULL;
1922-
_cleanup_free_ char *hid = NULL;
1921+
__cleanup_free char *hnqn = NULL;
1922+
__cleanup_free char *hid = NULL;
19231923
struct libnvme_host *h;
19241924
int err;
19251925

@@ -1998,7 +1998,7 @@ static int _nvmf_discovery(struct libnvme_global_ctx *ctx,
19981998
struct libnvmf_context *fctx, bool connect,
19991999
struct libnvme_ctrl *c)
20002000
{
2001-
_cleanup_free_ struct nvmf_discovery_log *log = NULL;
2001+
__cleanup_free struct nvmf_discovery_log *log = NULL;
20022002
libnvme_subsystem_t s = libnvme_ctrl_get_subsystem(c);
20032003
libnvme_host_t h = libnvme_subsystem_get_host(s);
20042004
uint64_t numrec;
@@ -2188,7 +2188,7 @@ static int nvmf_create_discovery_ctrl(struct libnvme_global_ctx *ctx,
21882188
struct libnvme_fabrics_config *cfg,
21892189
struct libnvme_ctrl **ctrl)
21902190
{
2191-
_cleanup_free_ struct nvme_id_ctrl *id = NULL;
2191+
__cleanup_free struct nvme_id_ctrl *id = NULL;
21922192
struct libnvme_ctrl *c;
21932193
int ret;
21942194

@@ -2487,8 +2487,8 @@ __public int libnvmf_discovery_config_file(struct libnvme_global_ctx *ctx,
24872487
__public int libnvmf_config_modify(struct libnvme_global_ctx *ctx,
24882488
struct libnvmf_context *fctx)
24892489
{
2490-
_cleanup_free_ char *hnqn = NULL;
2491-
_cleanup_free_ char *hid = NULL;
2490+
__cleanup_free char *hnqn = NULL;
2491+
__cleanup_free char *hid = NULL;
24922492
struct libnvme_host *h;
24932493
struct libnvme_subsystem *s;
24942494
struct libnvme_ctrl *c;
@@ -2896,7 +2896,7 @@ __public int libnvmf_discovery_nbft(struct libnvme_global_ctx *ctx,
28962896
/* Discovery Descriptor List */
28972897
for (dd = entry->nbft->discovery_list; dd && *dd; dd++) {
28982898
_cleanup_uri_ struct libnvme_fabrics_uri *uri = NULL;
2899-
_cleanup_free_ char *trsvcid = NULL;
2899+
__cleanup_free char *trsvcid = NULL;
29002900
struct libnvmf_context nfctx = *fctx;
29012901
bool persistent = false;
29022902
bool linked = false;

libnvme/src/nvme/json.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static struct json_object *parse_json(struct libnvme_global_ctx *ctx, int fd)
200200
char *str = NULL;
201201
_cleanup_tokener_ json_tokener *tok = NULL;
202202
int ret;
203-
_cleanup_free_ void *ptr = NULL;
203+
__cleanup_free void *ptr = NULL;
204204
int len = 0;
205205

206206
while ((ret = read(fd, buf, JSON_FILE_BUF_SIZE)) > 0) {

libnvme/src/nvme/lib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static int __nvme_transport_handle_open_direct(
127127
struct libnvme_transport_handle *hdl, const char *devname)
128128
{
129129
struct libnvme_passthru_cmd dummy = { 0 };
130-
_cleanup_free_ char *path = NULL;
130+
__cleanup_free char *path = NULL;
131131
char *name;
132132
int ret, id, ns;
133133
bool c = true;

libnvme/src/nvme/linux.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static int __nvme_set_attr(const char *path, const char *value)
7474

7575
int libnvme_set_attr(const char *dir, const char *attr, const char *value)
7676
{
77-
_cleanup_free_ char *path = NULL;
77+
__cleanup_free char *path = NULL;
7878
int ret;
7979

8080
ret = asprintf(&path, "%s/%s", dir, attr);
@@ -115,7 +115,7 @@ static char *__nvme_get_attr(const char *path)
115115

116116
__public char *libnvme_get_attr(const char *dir, const char *attr)
117117
{
118-
_cleanup_free_ char *path = NULL;
118+
__cleanup_free char *path = NULL;
119119
int ret;
120120

121121
ret = asprintf(&path, "%s/%s", dir, attr);
@@ -304,7 +304,7 @@ static int derive_retained_key(struct libnvme_global_ctx *ctx,
304304
size_t key_len)
305305
{
306306
_cleanup_evp_pkey_ctx_ EVP_PKEY_CTX *ectx = NULL;
307-
_cleanup_free_ uint8_t *hkdf_info = NULL;
307+
__cleanup_free uint8_t *hkdf_info = NULL;
308308
char *hkdf_label;
309309
const EVP_MD *md;
310310
size_t hmac_len;
@@ -373,7 +373,7 @@ static int derive_retained_key_compat(struct libnvme_global_ctx *ctx,
373373
unsigned char *retained, size_t key_len)
374374
{
375375
_cleanup_evp_pkey_ctx_ EVP_PKEY_CTX *ectx = NULL;
376-
_cleanup_free_ uint8_t *hkdf_info = NULL;
376+
__cleanup_free uint8_t *hkdf_info = NULL;
377377
const EVP_MD *md;
378378
size_t hmac_len;
379379
char *pos;
@@ -454,7 +454,7 @@ static int derive_tls_key(struct libnvme_global_ctx *ctx,
454454
unsigned char *retained, unsigned char *psk, size_t key_len)
455455
{
456456
_cleanup_evp_pkey_ctx_ EVP_PKEY_CTX *ectx = NULL;
457-
_cleanup_free_ uint8_t *hkdf_info = NULL;
457+
__cleanup_free uint8_t *hkdf_info = NULL;
458458
char *hkdf_label;
459459
const EVP_MD *md;
460460
size_t hmac_len;
@@ -531,7 +531,7 @@ static int derive_tls_key_compat(struct libnvme_global_ctx *ctx,
531531
unsigned char *retained, unsigned char *psk, size_t key_len)
532532
{
533533
_cleanup_evp_pkey_ctx_ EVP_PKEY_CTX *ectx = NULL;
534-
_cleanup_free_ uint8_t *hkdf_info = NULL;
534+
__cleanup_free uint8_t *hkdf_info = NULL;
535535
const EVP_MD *md;
536536
size_t hmac_len;
537537
char *pos;
@@ -680,7 +680,7 @@ static int derive_psk_digest(struct libnvme_global_ctx *ctx,
680680
static const char hmac_seed[] = "NVMe-over-Fabrics";
681681
_cleanup_ossl_lib_ctx_ OSSL_LIB_CTX *lib_ctx = NULL;
682682
_cleanup_evp_mac_ctx_ EVP_MAC_CTX *mac_ctx = NULL;
683-
_cleanup_free_ unsigned char *psk_ctx = NULL;
683+
__cleanup_free unsigned char *psk_ctx = NULL;
684684
_cleanup_evp_mac_ EVP_MAC *mac = NULL;
685685
OSSL_PARAM params[2], *p = params;
686686
size_t hmac_len;
@@ -820,7 +820,7 @@ static ssize_t getswordfish(struct libnvme_global_ctx *ctx,
820820
__public int libnvme_create_raw_secret(struct libnvme_global_ctx *ctx,
821821
const char *secret, size_t key_len, unsigned char **raw_secret)
822822
{
823-
_cleanup_free_ unsigned char *buf = NULL;
823+
__cleanup_free unsigned char *buf = NULL;
824824
int secret_len = 0, i, err;
825825
unsigned int c;
826826

@@ -904,8 +904,8 @@ static int derive_nvme_keys(struct libnvme_global_ctx *ctx,
904904
int hmac, unsigned char *configured,
905905
unsigned char *psk, int key_len, bool compat)
906906
{
907-
_cleanup_free_ unsigned char *retained = NULL;
908-
_cleanup_free_ char *digest = NULL;
907+
__cleanup_free unsigned char *retained = NULL;
908+
__cleanup_free char *digest = NULL;
909909
char *context = identity;
910910
unsigned char cipher;
911911
int ret = -1;
@@ -981,8 +981,8 @@ __public int libnvme_generate_tls_key_identity(struct libnvme_global_ctx *ctx,
981981
unsigned char *configured_key, int key_len,
982982
char **ident)
983983
{
984-
_cleanup_free_ unsigned char *psk = NULL;
985-
_cleanup_free_ char *identity = NULL;
984+
__cleanup_free unsigned char *psk = NULL;
985+
__cleanup_free char *identity = NULL;
986986
ssize_t identity_len;
987987
int ret;
988988

@@ -1018,8 +1018,8 @@ __public int libnvme_generate_tls_key_identity_compat(struct libnvme_global_ctx
10181018
int version, int hmac, unsigned char *configured_key,
10191019
int key_len, char **ident)
10201020
{
1021-
_cleanup_free_ unsigned char *psk = NULL;
1022-
_cleanup_free_ char *identity = NULL;
1021+
__cleanup_free unsigned char *psk = NULL;
1022+
__cleanup_free char *identity = NULL;
10231023
ssize_t identity_len;
10241024
int ret;
10251025

@@ -1068,7 +1068,7 @@ __public int libnvme_lookup_keyring(struct libnvme_global_ctx *ctx, const char *
10681068

10691069
__public char *libnvme_describe_key_serial(struct libnvme_global_ctx *ctx, long key_id)
10701070
{
1071-
_cleanup_free_ char *str = NULL;
1071+
__cleanup_free char *str = NULL;
10721072
char *last;
10731073

10741074
if (keyctl_describe_alloc(key_id, &str) < 0)
@@ -1224,8 +1224,8 @@ static int __nvme_insert_tls_key(struct libnvme_global_ctx *ctx,
12241224
int version, int hmac, unsigned char *configured_key,
12251225
int key_len, bool compat, long *keyp)
12261226
{
1227-
_cleanup_free_ unsigned char *psk = NULL;
1228-
_cleanup_free_ char *identity = NULL;
1227+
__cleanup_free unsigned char *psk = NULL;
1228+
__cleanup_free char *identity = NULL;
12291229
ssize_t identity_len;
12301230
long key;
12311231
int ret;
@@ -1333,7 +1333,7 @@ static int __nvme_import_tls_key(struct libnvme_global_ctx *ctx, long keyring_id
13331333
const char *identity, const char *key,
13341334
long *keyp)
13351335
{
1336-
_cleanup_free_ unsigned char *key_data = NULL;
1336+
__cleanup_free unsigned char *key_data = NULL;
13371337
unsigned char version;
13381338
unsigned char hmac;
13391339
size_t key_len;
@@ -1818,7 +1818,7 @@ static int uuid_from_product_uuid(char *system_uuid)
18181818
{
18191819
_cleanup_file_ FILE *stream = NULL;
18201820
ssize_t nread;
1821-
_cleanup_free_ char *line = NULL;
1821+
__cleanup_free char *line = NULL;
18221822
size_t len = 0;
18231823

18241824
stream = fopen(PATH_DMI_PROD_UUID, "re");

libnvme/src/nvme/log.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ __libnvme_msg(struct libnvme_global_ctx *ctx, int level,
4444
"[%s] <%s>%s ",
4545
"[%s] <%s> %s: ",
4646
};
47-
_cleanup_free_ char *header = NULL;
48-
_cleanup_free_ char *message = NULL;
47+
__cleanup_free char *header = NULL;
48+
__cleanup_free char *message = NULL;
4949
int idx = 0;
5050

5151
if (level > l->level)

0 commit comments

Comments
 (0)