From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Price Date: Wed, 14 Dec 2011 16:20:37 +0000 Subject: [Cluster-devel] [PATCH 2/2] libgfs2: Push down die() into the utils and remove it In-Reply-To: <1323879637-28987-1-git-send-email-anprice@redhat.com> References: <1323879637-28987-1-git-send-email-anprice@redhat.com> Message-ID: <1323879637-28987-2-git-send-email-anprice@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit This patch removes the definition of die() from libgfs2.h and pushes it down into the utils which still require it. In the case of gfs2_convert, which only had a few die() calls, it was dropped altogether. Signed-off-by: Andrew Price --- gfs2/convert/gfs2_convert.c | 18 ++++++++++++------ gfs2/edit/hexedit.h | 12 ++++++++++++ gfs2/fsck/util.c | 1 + gfs2/libgfs2/libgfs2.h | 12 ------------ gfs2/mkfs/gfs2_mkfs.h | 13 +++++++++++++ gfs2/quota/gfs2_quota.h | 13 +++++++++++++ gfs2/tool/gfs2_tool.h | 13 +++++++++++++ 7 files changed, 64 insertions(+), 18 deletions(-) diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c index 09a689c..ff5f50f 100644 --- a/gfs2/convert/gfs2_convert.c +++ b/gfs2/convert/gfs2_convert.c @@ -1847,8 +1847,10 @@ static void update_inode_file(struct gfs2_sbd *sdp) buf = cpu_to_be64(sdp->md.next_inum); count = gfs2_writei(ip, &buf, 0, sizeof(uint64_t)); - if (count != sizeof(uint64_t)) - die("update_inode_file\n"); + if (count != sizeof(uint64_t)) { + fprintf(stderr, "update_inode_file\n"); + exit(1); + } log_debug(_("\nNext Inum: %llu\n"), (unsigned long long)sdp->md.next_inum); }/* update_inode_file */ @@ -1869,8 +1871,10 @@ static void write_statfs_file(struct gfs2_sbd *sdp) gfs2_statfs_change_out(&sc, buf); count = gfs2_writei(ip, buf, 0, sizeof(struct gfs2_statfs_change)); - if (count != sizeof(struct gfs2_statfs_change)) - die("do_init (2)\n"); + if (count != sizeof(struct gfs2_statfs_change)) { + fprintf(stderr, "do_init (2)\n"); + exit(1); + } }/* write_statfs_file */ /* ------------------------------------------------------------------------- */ @@ -2043,8 +2047,10 @@ static void copy_quotas(struct gfs2_sbd *sdp) int err; err = gfs2_lookupi(sdp->master_dir, "quota", 5, &nq_ip); - if (err) - die(_("Couldn't lookup new quota file: %d\n"), err); + if (err) { + fprintf(stderr, _("Couldn't lookup new quota file: %d\n"), err); + exit(1); + } gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_quota_di); oq_ip = inode_read(sdp, inum.no_addr); diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h index 27950b0..b05b5c0 100644 --- a/gfs2/edit/hexedit.h +++ b/gfs2/edit/hexedit.h @@ -124,6 +124,18 @@ static inline int block_is_rgtree(void) #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; + fprintf(stderr, "%s: ", __FILE__); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + exit(-1); +} + /* Memory macros */ #define type_alloc(ptr, type, count) \ diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c index d912920..f37fe7d 100644 --- a/gfs2/fsck/util.c +++ b/gfs2/fsck/util.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index c356bbf..0e521fb 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -86,17 +85,6 @@ struct lgfs2_dev_info { uint64_t size; }; -static __inline__ __attribute__((noreturn, format (printf, 1, 2))) -void die(const char *fmt, ...) -{ - va_list ap; - fprintf(stderr, "%s: ", __FILE__); - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - exit(-1); -} - struct device { uint64_t length; }; diff --git a/gfs2/mkfs/gfs2_mkfs.h b/gfs2/mkfs/gfs2_mkfs.h index 6f0ac2b..d7d7da7 100644 --- a/gfs2/mkfs/gfs2_mkfs.h +++ b/gfs2/mkfs/gfs2_mkfs.h @@ -1,6 +1,7 @@ #ifndef __GFS2_MKFS_DOT_H__ #define __GFS2_MKFS_DOT_H__ +#include #include #include "osi_list.h" #include "copyright.cf" @@ -18,6 +19,18 @@ extern void main_mkfs(int argc, char *argv[]); /* main_shrink */ extern void main_shrink(int argc, char *argv[]); +/* die() used to be in libgfs2.h */ +static __inline__ __attribute__((noreturn, format (printf, 1, 2))) +void die(const char *fmt, ...) +{ + va_list ap; + fprintf(stderr, "%s: ", __FILE__); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + exit(-1); +} + /* * The following inode IOCTL macros and inode flags * are copied from linux/fs.h, because we have duplicate diff --git a/gfs2/quota/gfs2_quota.h b/gfs2/quota/gfs2_quota.h index 80c0d3f..744f02b 100644 --- a/gfs2/quota/gfs2_quota.h +++ b/gfs2/quota/gfs2_quota.h @@ -1,6 +1,7 @@ #ifndef __GFS2_QUOTA_DOT_H__ #define __GFS2_QUOTA_DOT_H__ +#include #include "libgfs2.h" #include @@ -79,4 +80,16 @@ void do_quota_init(struct gfs2_sbd *sdp, commandline_t *comline); uint32_t name_to_id(int user, char *name, int numbers); char *id_to_name(int user, uint32_t id, int numbers); +/* die() used to be in libgfs2.h */ +static __inline__ __attribute__((noreturn, format (printf, 1, 2))) +void die(const char *fmt, ...) +{ + va_list ap; + fprintf(stderr, "%s: ", __FILE__); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + exit(-1); +} + #endif /* __GFS2_QUOTA_DOT_H__ */ diff --git a/gfs2/tool/gfs2_tool.h b/gfs2/tool/gfs2_tool.h index 884856f..3a181ff 100644 --- a/gfs2/tool/gfs2_tool.h +++ b/gfs2/tool/gfs2_tool.h @@ -1,6 +1,7 @@ #ifndef __GFS2_TOOL_DOT_H__ #define __GFS2_TOOL_DOT_H__ +#include #define OUTPUT_BLOCKS 0 #define OUTPUT_K 1 @@ -48,4 +49,16 @@ void do_sb(int argc, char **argv); void get_tune(int argc, char **argv); void set_tune(int argc, char **argv); +/* die() used to be in libgfs2.h */ +static __inline__ __attribute__((noreturn, format (printf, 1, 2))) +void die(const char *fmt, ...) +{ + va_list ap; + fprintf(stderr, "%s: ", __FILE__); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + exit(-1); +} + #endif /* __GFS2_TOOL_DOT_H__ */ -- 1.7.6.4