Re: [Cluster-devel] [PATCH 2/3] fsck.gfs2: Simplify bad_journalname
- Original Message - Remove the need for a temporary string and strncpy call by passing the length of the string to printf. Signed-off-by: Andrew Price anpr...@redhat.com --- gfs2/fsck/initialize.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index 1ab078b..c052205 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -1513,14 +1513,10 @@ static int init_rindex(struct gfs2_sbd *sdp) static void bad_journalname(const char *filename, int len) { - char tmp_name[64]; - if (len = 64) len = 63; - strncpy(tmp_name, filename, len); - tmp_name[len] = '\0'; - log_debug(_(Journal index entry '%s' has an invalid filename.\n), - tmp_name); + log_debug(_(Journal index entry '%.*s' has an invalid filename.\n), + len, filename); } /** -- 1.9.3 Nice trick (strangely, I've never used that construct), but we could just as well get rid of the whole function altogether. Bob Peterson Red Hat File Systems
Re: [Cluster-devel] [PATCH 3/3] gfs2-utils build: Add a configure script summary
- Original Message - Print a nicely formatted summary of some of the more interesting configure options. Required some tweaking of earlier configure stages for accuracy. Signed-off-by: Andrew Price anpr...@redhat.com --- Hi, ACK Bob Peterson Red Hat File Systems
Re: [Cluster-devel] [PATCH 1/3] fsck.gfs2: Fix 'initializer element is not constant' build error
- Original Message - This error occurs when gfs2-utils is compiled with -std options more recent than gnu89: CC fsck_gfs2-main.o main.c:39:38: error: initializer element is not constant struct osi_root dup_blocks = (struct osi_root) { NULL, }; ^ main.c:40:35: error: initializer element is not constant struct osi_root dirtree = (struct osi_root) { NULL, }; ^ main.c:41:37: error: initializer element is not constant struct osi_root inodetree = (struct osi_root) { NULL, }; ^ As far as I can tell, with C89/gnu89 the use of a cast in this context is undefined behaviour and the later standards are more strict about it, hence the error. As the standards specify that members of objects with static storage duration are zeroed/NULLed anyway, the initializers can be removed to achieve the intended result. Signed-off-by: Andrew Price anpr...@redhat.com --- ACK Bob Peterson Red Hat File Systems
Re: [Cluster-devel] [PATCH 2/3] fsck.gfs2: Simplify bad_journalname
On 28/01/15 13:13, Bob Peterson wrote: - Original Message - Remove the need for a temporary string and strncpy call by passing the length of the string to printf. Signed-off-by: Andrew Price anpr...@redhat.com --- gfs2/fsck/initialize.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index 1ab078b..c052205 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -1513,14 +1513,10 @@ static int init_rindex(struct gfs2_sbd *sdp) static void bad_journalname(const char *filename, int len) { - char tmp_name[64]; - if (len = 64) len = 63; - strncpy(tmp_name, filename, len); - tmp_name[len] = '\0'; - log_debug(_(Journal index entry '%s' has an invalid filename.\n), - tmp_name); + log_debug(_(Journal index entry '%.*s' has an invalid filename.\n), + len, filename); } /** -- 1.9.3 Nice trick (strangely, I've never used that construct), but we could just as well get rid of the whole function altogether. I did consider removing it but, due to if-nesting and being called from two places, it makes things cleaner to leave it in a separate function. When fsck.gfs2 is fast enough that we need to worry about function call overhead then maybe we can inline it :) Thanks, Andy