Skip to content

Commit 3228c78

Browse files
committed
cleanup: rename _cleanup_fd_ to __cleanup_fd
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 fd90948 commit 3228c78

10 files changed

Lines changed: 25 additions & 25 deletions

File tree

fabrics.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ int fabrics_config(const char *desc, int argc, char **argv)
958958
}
959959

960960
if (update_config) {
961-
_cleanup_fd_ int fd = -1;
961+
__cleanup_fd int fd = -1;
962962

963963
fd = open(config_file, O_RDONLY, 0);
964964
if (fd != -1)

libnvme/src/nvme/cleanup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static inline void cleanup_fd(int *fd)
4242
if (*fd >= 0)
4343
close(*fd);
4444
}
45-
#define _cleanup_fd_ __cleanup(cleanup_fd)
45+
#define __cleanup_fd __cleanup(cleanup_fd)
4646

4747
static inline DEFINE_CLEANUP_FUNC(cleanup_addrinfo, struct addrinfo *, freeaddrinfo)
4848
#define _cleanup_addrinfo_ __cleanup(cleanup_addrinfo)

libnvme/src/nvme/fabrics.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ static int build_options(libnvme_host_t h, libnvme_ctrl_t c, char **argstr)
862862
static int __nvmf_supported_options(struct libnvme_global_ctx *ctx)
863863
{
864864
char buf[0x1000], *options, *p, *v;
865-
_cleanup_fd_ int fd = -1;
865+
__cleanup_fd int fd = -1;
866866
ssize_t len;
867867

868868
if (ctx->options)
@@ -949,7 +949,7 @@ static int __nvmf_supported_options(struct libnvme_global_ctx *ctx)
949949

950950
static int __nvmf_add_ctrl(struct libnvme_global_ctx *ctx, const char *argstr)
951951
{
952-
_cleanup_fd_ int fd = -1;
952+
__cleanup_fd int fd = -1;
953953
int ret, len = strlen(argstr);
954954
char buf[0x1000], *options, *p;
955955

libnvme/src/nvme/linux.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
static int __nvme_set_attr(const char *path, const char *value)
6161
{
62-
_cleanup_fd_ int fd = -1;
62+
__cleanup_fd int fd = -1;
6363

6464
fd = open(path, O_WRONLY);
6565
if (fd < 0) {
@@ -763,7 +763,7 @@ static ssize_t getrandom_bytes(void *buf, size_t buflen)
763763
#if HAVE_SYS_RANDOM
764764
result = getrandom(buf, buflen, GRND_NONBLOCK);
765765
#else
766-
_cleanup_fd_ int fd = -1;
766+
__cleanup_fd int fd = -1;
767767

768768
fd = open("/dev/urandom", O_RDONLY);
769769
if (fd < 0)
@@ -1706,7 +1706,7 @@ __public int libnvme_import_tls_key(struct libnvme_global_ctx *ctx, const char *
17061706

17071707
static int uuid_from_device_tree(char *system_uuid)
17081708
{
1709-
_cleanup_fd_ int f = -1;
1709+
__cleanup_fd int f = -1;
17101710
ssize_t len;
17111711

17121712
f = open(libnvme_uuid_ibm_filename(), O_RDONLY);
@@ -1901,7 +1901,7 @@ __public char *libnvme_generate_hostnqn(void)
19011901
static char *nvmf_read_file(const char *f, int len)
19021902
{
19031903
char buf[len];
1904-
_cleanup_fd_ int fd = -1;
1904+
__cleanup_fd int fd = -1;
19051905
int ret;
19061906

19071907
fd = open(f, O_RDONLY);

libnvme/src/nvme/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ __public int libnvme_uuid_from_string(const char *str, unsigned char uuid[NVME_U
752752

753753
__public int libnvme_random_uuid(unsigned char uuid[NVME_UUID_LEN])
754754
{
755-
_cleanup_fd_ int f = -1;
755+
__cleanup_fd int f = -1;
756756
ssize_t n;
757757

758758
f = open("/dev/urandom", O_RDONLY);

nvme.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ static int get_telemetry_log(int argc, char **argv, struct command *acmd,
823823
__cleanup_free struct nvme_id_ctrl *id_ctrl = NULL;
824824
_cleanup_nvme_global_ctx_ struct libnvme_global_ctx *ctx = NULL;
825825
_cleanup_nvme_transport_handle_ struct libnvme_transport_handle *hdl = NULL;
826-
_cleanup_fd_ int output = -1;
826+
__cleanup_fd int output = -1;
827827
int err = 0;
828828
size_t total_size = 0;
829829
__u8 *data_ptr = NULL;
@@ -1831,7 +1831,7 @@ static int get_boot_part_log(int argc, char **argv, struct command *acmd, struct
18311831
__cleanup_free __u8 *bp_log = NULL;
18321832
nvme_print_flags_t flags;
18331833
int err = -1;
1834-
_cleanup_fd_ int output = -1;
1834+
__cleanup_fd int output = -1;
18351835
__u32 bpsz = 0;
18361836

18371837
struct config {
@@ -2111,7 +2111,7 @@ static int io_mgmt_send(int argc, char **argv, struct command *acmd, struct plug
21112111

21122112
_cleanup_nvme_transport_handle_ struct libnvme_transport_handle *hdl = NULL;
21132113
_cleanup_nvme_global_ctx_ struct libnvme_global_ctx *ctx = NULL;
2114-
_cleanup_fd_ int dfd = STDIN_FILENO;
2114+
__cleanup_fd int dfd = STDIN_FILENO;
21152115
__cleanup_free void *buf = NULL;
21162116
struct libnvme_passthru_cmd cmd;
21172117
int err = -1;
@@ -2189,7 +2189,7 @@ static int io_mgmt_recv(int argc, char **argv, struct command *acmd, struct plug
21892189
_cleanup_nvme_global_ctx_ struct libnvme_global_ctx *ctx = NULL;
21902190
__cleanup_free void *buf = NULL;
21912191
struct libnvme_passthru_cmd cmd;
2192-
_cleanup_fd_ int dfd = -1;
2192+
__cleanup_fd int dfd = -1;
21932193
int err = -1;
21942194

21952195
struct config {
@@ -5124,7 +5124,7 @@ static int fw_download(int argc, char **argv, struct command *acmd, struct plugi
51245124
_cleanup_nvme_global_ctx_ struct libnvme_global_ctx *ctx = NULL;
51255125
_cleanup_nvme_transport_handle_ struct libnvme_transport_handle *hdl = NULL;
51265126
_cleanup_huge_ struct nvme_mem_huge mh = { 0, };
5127-
_cleanup_fd_ int fw_fd = -1;
5127+
__cleanup_fd int fw_fd = -1;
51285128
unsigned int fw_size, pos;
51295129
int err;
51305130
struct stat sb;
@@ -6861,7 +6861,7 @@ static int set_feature(int argc, char **argv, struct command *acmd, struct plugi
68616861
_cleanup_nvme_global_ctx_ struct libnvme_global_ctx *ctx = NULL;
68626862
_cleanup_nvme_transport_handle_ struct libnvme_transport_handle *hdl = NULL;
68636863
__cleanup_free void *buf = NULL;
6864-
_cleanup_fd_ int ffd = STDIN_FILENO;
6864+
__cleanup_fd int ffd = STDIN_FILENO;
68656865
int err;
68666866
__u64 result;
68676867
nvme_print_flags_t flags;
@@ -7007,7 +7007,7 @@ static int sec_send(int argc, char **argv, struct command *acmd, struct plugin *
70077007
_cleanup_nvme_transport_handle_ struct libnvme_transport_handle *hdl = NULL;
70087008
struct libnvme_passthru_cmd cmd;
70097009
__cleanup_free void *sec_buf = NULL;
7010-
_cleanup_fd_ int sec_fd = -1;
7010+
__cleanup_fd int sec_fd = -1;
70117011
unsigned int sec_size;
70127012
int err;
70137013
nvme_print_flags_t flags;
@@ -7120,7 +7120,7 @@ static int dir_send(int argc, char **argv, struct command *acmd, struct plugin *
71207120
__cleanup_free void *buf = NULL;
71217121
struct libnvme_passthru_cmd cmd;
71227122
__u32 dw12 = 0;
7123-
_cleanup_fd_ int ffd = STDIN_FILENO;
7123+
__cleanup_fd int ffd = STDIN_FILENO;
71247124
int err;
71257125

71267126
struct config {
@@ -8322,7 +8322,7 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char
83228322
unsigned int logical_block_size = 0;
83238323
struct timeval start_time, end_time;
83248324
__cleanup_free void *mbuffer = NULL;
8325-
_cleanup_fd_ int dfd = -1, mfd = -1;
8325+
__cleanup_fd int dfd = -1, mfd = -1;
83268326
__u16 control = 0, nblocks = 0;
83278327
struct libnvme_passthru_cmd cmd;
83288328
__u8 sts = 0, pif = 0;
@@ -9274,7 +9274,7 @@ static int passthru(int argc, char **argv, bool admin,
92749274
_cleanup_huge_ struct nvme_mem_huge mh = { 0, };
92759275
_cleanup_nvme_global_ctx_ struct libnvme_global_ctx *ctx = NULL;
92769276
_cleanup_nvme_transport_handle_ struct libnvme_transport_handle *hdl = NULL;
9277-
_cleanup_fd_ int dfd = -1, mfd = -1;
9277+
__cleanup_fd int dfd = -1, mfd = -1;
92789278
int flags;
92799279
int mode = 0644;
92809280
void *data = NULL;
@@ -10426,7 +10426,7 @@ static int libnvme_mi(int argc, char **argv, __u8 admin_opcode, const char *desc
1042610426
void *data = NULL;
1042710427
int err = 0;
1042810428
bool send;
10429-
_cleanup_fd_ int fd = -1;
10429+
__cleanup_fd int fd = -1;
1043010430
int flags;
1043110431
_cleanup_huge_ struct nvme_mem_huge mh = { 0, };
1043210432
_cleanup_nvme_global_ctx_ struct libnvme_global_ctx *ctx = NULL;

plugins/feat/feat-nvme.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static int perfc_set(struct libnvme_transport_handle *hdl, __u8 fid, __u32 cdw11
174174
__u64 result;
175175
int err;
176176

177-
_cleanup_fd_ int ffd = STDIN_FILENO;
177+
__cleanup_fd int ffd = STDIN_FILENO;
178178

179179
struct nvme_perf_characteristics data = {
180180
.attr_buf = { 0 },

plugins/ocp/ocp-nvme.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,7 @@ static int get_c9_log_page_data(struct libnvme_transport_handle *hdl,
12801280
__le64 vu_event_str_table_ofst = 0;
12811281
__le64 ascii_table_ofst = 0;
12821282

1283-
_cleanup_fd_ int fd = STDIN_FILENO;
1283+
__cleanup_fd int fd = STDIN_FILENO;
12841284

12851285
header_data = (__u8 *)malloc(sizeof(__u8) * C9_TELEMETRY_STR_LOG_LEN);
12861286
if (!header_data) {
@@ -2713,7 +2713,7 @@ static int get_error_injection(int argc, char **argv, struct command *acmd, stru
27132713
static int error_injection_set(struct libnvme_transport_handle *hdl, struct erri_config *cfg, bool uuid, __u32 nsid)
27142714
{
27152715
__cleanup_free struct erri_entry *entry = NULL;
2716-
_cleanup_fd_ int ffd = -1;
2716+
__cleanup_fd int ffd = -1;
27172717
__u32 data_len;
27182718
__u8 uidx = 0;
27192719
int err;

plugins/solidigm/solidigm-internal-logs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ struct log {
465465
static int log_save(struct log *log, const char *parent_dir_name, const char *subdir_name,
466466
const char *file_name, __u8 *buffer, size_t buf_size)
467467
{
468-
_cleanup_fd_ int output = -1;
468+
__cleanup_fd int output = -1;
469469
__cleanup_free char *file_path = NULL;
470470
size_t bytes_remaining = 0;
471471

util/cleanup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static inline void cleanup_fd(int *fd)
3434
if (*fd > STDERR_FILENO)
3535
close(*fd);
3636
}
37-
#define _cleanup_fd_ __cleanup(cleanup_fd)
37+
#define __cleanup_fd __cleanup(cleanup_fd)
3838

3939
static inline void cleanup_nvme_global_ctx(struct libnvme_global_ctx **ctx)
4040
{

0 commit comments

Comments
 (0)