This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch main in repository gfs2-utils.
commit 06d0d9f142c0012bdcf617016f60fc8327bad88b Author: Andrew Price anprice@redhat.com AuthorDate: Fri Jan 14 10:58:09 2022 +0000
gfs2_edit: Remove the remaining die() calls
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/edit/hexedit.c | 16 ++++++++++------ gfs2/edit/hexedit.h | 11 ----------- gfs2/edit/savemeta.c | 28 +++++++++++++++++----------- 3 files changed, 27 insertions(+), 28 deletions(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c index cf121204..773fbb39 100644 --- a/gfs2/edit/hexedit.c +++ b/gfs2/edit/hexedit.c @@ -2317,8 +2317,8 @@ static void process_parameters(int argc, char *argv[], int pass) uint64_t keyword_blk;
if (argc < 2) { - usage(); - die("no device specified\n"); + fprintf(stderr, "No device specified\n"); + exit(1); } for (i = 1; i < argc; i++) { if (!pass) { /* first pass */ @@ -2500,8 +2500,10 @@ int main(int argc, char *argv[]) int i, j, fd;
indirect = malloc(sizeof(struct iinfo)); - if (!indirect) - die("Out of memory."); + if (indirect == NULL) { + perror("Failed to allocate indirect info"); + exit(1); + } memset(indirect, 0, sizeof(struct iinfo)); memset(start_row, 0, sizeof(start_row)); memset(lines_per_row, 0, sizeof(lines_per_row)); @@ -2533,8 +2535,10 @@ int main(int argc, char *argv[]) dmode = HEX_MODE;
fd = open(device, O_RDWR); - if (fd < 0) - die("can't open %s: %s\n", device, strerror(errno)); + if (fd < 0) { + fprintf(stderr, "Failed to open '%s': %s\n", device, strerror(errno)); + exit(1); + } max_block = lseek(fd, 0, SEEK_END) / sbd.sd_bsize;
read_superblock(fd); diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h index 3b1d8e86..543cc3ab 100644 --- a/gfs2/edit/hexedit.h +++ b/gfs2/edit/hexedit.h @@ -128,17 +128,6 @@ static inline int block_is_journals(uint64_t blk) #define SCREEN_HEIGHT (16) #define SCREEN_WIDTH (16)
-/* die() used to be in libgfs2.h */ -static __inline__ __attribute__((noreturn, format (printf, 1, 2))) -void die(const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - exit(-1); -} - #define TITLE1 "gfs2_edit - Global File System Editor (use with extreme caution)" #define TITLE2 REDHAT_COPYRIGHT " - Press H for help"
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c index 2d53ff10..8fde8c8a 100644 --- a/gfs2/edit/savemeta.c +++ b/gfs2/edit/savemeta.c @@ -1324,11 +1324,10 @@ static int restore_data(int fd, struct metafd *mfd, int printonly) return 0; }
-static void complain(const char *complaint) +static void restoremeta_usage(void) { - fprintf(stderr, "%s\n", complaint); - die("Format is: \ngfs2_edit restoremeta <file to restore> " - "<dest file system>\n"); + fprintf(stderr, "Usage:\n"); + fprintf(stderr, "gfs2_edit restoremeta <metadata_file> <block_device>\n"); }
static int restore_init(const char *path, struct metafd *mfd, int printonly) @@ -1413,16 +1412,23 @@ void restoremeta(const char *in_fn, const char *out_device, uint64_t printonly) int error;
termlines = 0; - if (!in_fn) - complain("No source file specified."); - if (!printonly && !out_device) - complain("No destination file system specified."); - + if (in_fn == NULL || in_fn[0] == '\0') { + fprintf(stderr, "No source file specified."); + restoremeta_usage(); + exit(1); + } + if (!printonly && (out_device == NULL || out_device[0] == '\0')) { + fprintf(stderr, "No destination file system specified."); + restoremeta_usage(); + exit(1); + } if (!printonly) { sbd.device_fd = open(out_device, O_RDWR); - if (sbd.device_fd < 0) - die("Can't open destination file system %s: %s\n", + if (sbd.device_fd < 0) { + fprintf(stderr, "Failed to open target '%s': %s\n", out_device, strerror(errno)); + exit(1); + } } else if (out_device) /* for printsavedmeta, the out_device is an optional block no */ printonly = check_keywords(out_device);
cluster-commits@lists.fedorahosted.org