Skip to content

Commit a27de2b

Browse files
committed
fix: iokit_set_xattr reported success as failure
The function collected DEVICE_GOOD in ret when one of the vendor attributes matched, but returned the hardcoded initial error, so every successful set was reported as -LTFS_NO_XATTR. Return ret, matching the sg backend. Found by -Wunused-but-set-variable. Also remove two write-only variables in the same file.
1 parent 476758e commit a27de2b

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

src/tape_drivers/osx/iokit/iokit_tape.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static int _get_dump(struct iokit_data *priv, char *fname)
285285
long long data_length, buf_offset;
286286
int dumpfd = -1;
287287
int transfer_size, num_transfers, excess_transfer;
288-
int i, bytes;
288+
int bytes;
289289
unsigned char cap_buf[DUMP_HEADER_SIZE];
290290
unsigned char *dump_buf;
291291
int buf_id;
@@ -331,14 +331,11 @@ static int _get_dump(struct iokit_data *priv, char *fname)
331331

332332
/* start to transfer data */
333333
buf_offset = 0;
334-
i = 0;
335334
ltfsmsg(LTFS_DEBUG, 30859D);
336335
while(num_transfers)
337336
{
338337
int length;
339338

340-
i++;
341-
342339
/* Allocation Length is transfer_size or excess_transfer*/
343340
if(excess_transfer && num_transfers == 1)
344341
length = excess_transfer;
@@ -3412,7 +3409,9 @@ int iokit_set_xattr(void *device, const char *name, const char *buf, size_t size
34123409
free(null_terminated);
34133410

34143411
ltfs_profiler_add_entry(priv->profiler, NULL, TAPEBEND_REQ_EXIT(REQ_TC_SETXATTR));
3415-
return -LTFS_NO_XATTR;
3412+
/* ret is DEVICE_GOOD when one of the vendor attributes matched above;
3413+
* returning the hardcoded failure reported success as an error. */
3414+
return ret;
34163415
}
34173416

34183417
#define BLOCKLEN_DATA_SIZE 6
@@ -3629,7 +3628,7 @@ static const char *_generate_product_name(const char *product_id)
36293628

36303629
int iokit_get_device_list(struct tc_drive_info *buf, int count)
36313630
{
3632-
int i, ret;
3631+
int i;
36333632
int found = 0;
36343633
int32_t devs = iokit_get_ssc_device_count();
36353634
int drive_type;
@@ -3646,10 +3645,7 @@ int iokit_get_device_list(struct tc_drive_info *buf, int count)
36463645
if( devs > 0 ) {
36473646
for (i = 0; i < devs; i++) {
36483647
if(iokit_find_ssc_device(iokit_device, i) != 0)
3649-
{
3650-
ret = -EDEV_DEVICE_UNOPENABLE;
36513648
continue;
3652-
}
36533649
drive_type = iokit_get_drive_identifier(iokit_device, &identifier);
36543650
if (!drive_type) {
36553651
if (found < count && buf) {
@@ -3665,7 +3661,7 @@ int iokit_get_device_list(struct tc_drive_info *buf, int count)
36653661
}
36663662
found ++;
36673663
}
3668-
ret = iokit_free_device(iokit_device);
3664+
iokit_free_device(iokit_device);
36693665
}
36703666
}
36713667

0 commit comments

Comments
 (0)