Skip to content

Commit b959a9a

Browse files
committed
btrfs-progs: map-logical: use message helpers for error messages
Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 9721562 commit b959a9a

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

btrfs-find-root.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ int main(int argc, char **argv)
391391
ret = btrfs_find_root_search(fs_info, &filter, &result, &found);
392392
if (ret < 0) {
393393
errno = -ret;
394-
fprintf(stderr, "Fail to search the tree root: %m\n");
394+
error("fail to search the tree root: %m");
395395
goto out;
396396
}
397397
if (ret > 0) {

btrfs-map-logical.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ static int write_extent_content(struct btrfs_fs_info *fs_info, int out_fd,
182182
mirror);
183183
if (ret < 0) {
184184
errno = -ret;
185-
fprintf(stderr,
186-
"Failed to read extent at [%llu, %llu]: %m\n",
185+
error("failed to read extent at [%llu, %llu]: %m",
187186
logical, logical + length);
188187
return ret;
189188
}
@@ -192,7 +191,7 @@ static int write_extent_content(struct btrfs_fs_info *fs_info, int out_fd,
192191
if (ret > 0)
193192
ret = -EINTR;
194193
errno = -ret;
195-
fprintf(stderr, "output file write failed: %m\n");
194+
error("output file write failed: %m");
196195
return ret;
197196
}
198197
cur_offset += cur_len;
@@ -270,7 +269,7 @@ int main(int argc, char **argv)
270269

271270
root = open_ctree(dev, 0, 0);
272271
if (!root) {
273-
fprintf(stderr, "Open ctree failed\n");
272+
error("open ctree failed");
274273
free(output_file);
275274
exit(1);
276275
}
@@ -303,7 +302,7 @@ int main(int argc, char **argv)
303302
ret = map_one_extent(root->fs_info, &cur_logical, &cur_len, 0);
304303
if (ret < 0) {
305304
errno = -ret;
306-
fprintf(stderr, "Failed to find extent at [%llu,%llu): %m\n",
305+
error("failed to find extent at [%llu,%llu): %m",
307306
cur_logical, cur_logical + cur_len);
308307
goto out_close_fd;
309308
}
@@ -316,14 +315,12 @@ int main(int argc, char **argv)
316315
ret = map_one_extent(root->fs_info, &cur_logical, &cur_len, 1);
317316
if (ret < 0) {
318317
errno = -ret;
319-
fprintf(stderr,
320-
"Failed to find extent at [%llu,%llu): %m\n",
318+
error("Failed to find extent at [%llu,%llu): %m",
321319
cur_logical, cur_logical + cur_len);
322320
goto out_close_fd;
323321
}
324322
if (ret > 0) {
325-
fprintf(stderr,
326-
"Failed to find any extent at [%llu,%llu)\n",
323+
error("failed to find any extent at [%llu,%llu)",
327324
cur_logical, cur_logical + cur_len);
328325
goto out_close_fd;
329326
}
@@ -363,7 +360,7 @@ int main(int argc, char **argv)
363360
}
364361

365362
if (!found) {
366-
fprintf(stderr, "No extent found at range [%llu,%llu)\n",
363+
error("no extent found at range [%llu,%llu)",
367364
logical, logical + bytes);
368365
}
369366
out_close_fd:

0 commit comments

Comments
 (0)