All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 7/8] cleanup: move fold_t out of util.h
Date: Fri, 16 Oct 2015 12:45:00 +1100	[thread overview]
Message-ID: <1444959901-31319-8-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1444959901-31319-1-git-send-email-david@fromorbit.com>

From: Dave Chinner <dchinner@redhat.com>

Many files just want the fold_t type, but pulling in util.h requires
all the XFS and JDM headers to be pulled in, too. Move fold_t to
mlog.[ch] as it tends to be common with log output. Similarly, move
the PREEMPT_* definitions to common/types.h to remove that
dependency on util.h as well.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 common/mlog.c  | 45 +++++++++++++++++++++++++++++++++++++++++++++
 common/mlog.h  |  6 ++++++
 common/types.h |  5 +++++
 common/util.c  | 45 ---------------------------------------------
 common/util.h  | 11 -----------
 5 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/mlog.c b/common/mlog.c
index fd21c18..c8b3129 100644
--- a/common/mlog.c
+++ b/common/mlog.c
@@ -802,3 +802,48 @@ mlog_sym_lookup( char *sym )
 
 	return -1;
 }
+
+void
+fold_init( fold_t fold, char *infostr, char c )
+{
+	size_t infolen;
+	size_t dashlen;
+	size_t predashlen;
+	size_t postdashlen;
+	char *p;
+	char *endp;
+	ix_t cnt;
+
+	assert( sizeof( fold_t ) == FOLD_LEN + 1 );
+
+	infolen = strlen( infostr );
+	if ( infolen > FOLD_LEN - 4 ) {
+		infolen = FOLD_LEN - 4;
+	}
+	dashlen = FOLD_LEN - infolen - 3;
+	predashlen = dashlen / 2;
+	postdashlen = dashlen - predashlen;
+
+	p = &fold[ 0 ];
+	endp = &fold[ sizeof( fold_t ) - 1 ];
+
+	assert( p < endp );
+	*p++ = ' ';
+	for ( cnt = 0 ; cnt < predashlen && p < endp ; cnt++, p++ ) {
+		*p = c;
+	}
+	assert( p < endp );
+	*p++ = ' ';
+	assert( p < endp );
+	assert( p + infolen < endp );
+	strcpy( p, infostr );
+	p += infolen;
+	assert( p < endp );
+	*p++ = ' ';
+	assert( p < endp );
+	for ( cnt = 0 ; cnt < postdashlen && p < endp ; cnt++, p++ ) {
+		*p = c;
+	}
+	assert( p <= endp );
+	*p = 0;
+}
diff --git a/common/mlog.h b/common/mlog.h
index d7bbfce..e080f9e 100644
--- a/common/mlog.h
+++ b/common/mlog.h
@@ -123,4 +123,10 @@ extern void mlog_exit_flush( void );
 extern void mlog_lock( void );
 extern void mlog_unlock( void );
 
+/* fold_t - a character string made to look like a "fold here"
+ */
+#define FOLD_LEN	79
+typedef char fold_t[ FOLD_LEN + 1 ];
+extern void fold_init( fold_t fold, char *infostr, char c );
+
 #endif /* MLOG_H */
diff --git a/common/types.h b/common/types.h
index 0923897..f902828 100644
--- a/common/types.h
+++ b/common/types.h
@@ -136,4 +136,9 @@ typedef struct stat64 stat64_t;
 typedef struct getbmapx getbmapx_t;
 typedef struct fsdmidata fsdmidata_t;
 
+/* flg definitions for preemptchk 
+ */
+#define PREEMPT_FULL		0
+#define PREEMPT_PROGRESSONLY	1
+
 #endif /* TYPES_H */
diff --git a/common/util.c b/common/util.c
index 93dd9c8..0d49d5c 100644
--- a/common/util.c
+++ b/common/util.c
@@ -532,48 +532,3 @@ cvtnum( int blocksize, char *s )
 		return 1024 * 1024 * i;
 	return -1;
 }
-
-void
-fold_init( fold_t fold, char *infostr, char c )
-{
-	size_t infolen;
-	size_t dashlen;
-	size_t predashlen;
-	size_t postdashlen;
-	char *p;
-	char *endp;
-	ix_t cnt;
-
-	assert( sizeof( fold_t ) == FOLD_LEN + 1 );
-
-	infolen = strlen( infostr );
-	if ( infolen > FOLD_LEN - 4 ) {
-		infolen = FOLD_LEN - 4;
-	}
-	dashlen = FOLD_LEN - infolen - 3;
-	predashlen = dashlen / 2;
-	postdashlen = dashlen - predashlen;
-
-	p = &fold[ 0 ];
-	endp = &fold[ sizeof( fold_t ) - 1 ];
-
-	assert( p < endp );
-	*p++ = ' ';
-	for ( cnt = 0 ; cnt < predashlen && p < endp ; cnt++, p++ ) {
-		*p = c;
-	}
-	assert( p < endp );
-	*p++ = ' ';
-	assert( p < endp );
-	assert( p + infolen < endp );
-	strcpy( p, infostr );
-	p += infolen;
-	assert( p < endp );
-	*p++ = ' ';
-	assert( p < endp );
-	for ( cnt = 0 ; cnt < postdashlen && p < endp ; cnt++, p++ ) {
-		*p = c;
-	}
-	assert( p <= endp );
-	*p = 0;
-}
diff --git a/common/util.h b/common/util.h
index 5284811..558bf7e 100644
--- a/common/util.h
+++ b/common/util.h
@@ -143,22 +143,11 @@ extern int diriter( jdm_fshandle_t *fshandlep,
 			 size_t usrgdsz );
 
 
-/* fold_t - a character string made to look like a "fold here"
- */
-#define FOLD_LEN	79
-typedef char fold_t[ FOLD_LEN + 1 ];
-extern void fold_init( fold_t fold, char *infostr, char c );
-
 
 /* macro to copy uuid structures
  */
 #define COPY_LABEL( lab1, lab2) ( bcopy( lab1, lab2, GLOBAL_HDR_STRING_SZ) )
 
-/* flg definitions for preemptchk 
- */
-#define PREEMPT_FULL		0
-#define PREEMPT_PROGRESSONLY	1
-
 /*
  * Align pointer up to alignment
  */
-- 
2.5.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2015-10-16  1:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-16  1:44 [PATCH 0/8] xfsdump: Ouchie! My bleeding eyes! Dave Chinner
2015-10-16  1:44 ` [PATCH 1/8] cleanup: get rid of ASSERT Dave Chinner
2015-10-28 11:51   ` Brian Foster
2015-10-28 22:32     ` Dave Chinner
2015-10-29 12:13       ` Brian Foster
2015-10-29 22:26         ` Dave Chinner
2015-10-30 11:39           ` Brian Foster
2015-10-16  1:44 ` [PATCH 2/8] build: don't rely on xfs/xfs.h to include necessary headers Dave Chinner
2015-10-16  1:44 ` [PATCH 3/8] cleanup: kill intgen_t Dave Chinner
2015-10-16  1:44 ` [PATCH 4/8] cleanup: kill u_int*_t types Dave Chinner
2015-10-16  1:44 ` [PATCH 5/8] cleanup: define a local xfs_ino_t Dave Chinner
2015-10-16  1:44 ` [PATCH 6/8] cleanup: use system uuid.h headers Dave Chinner
2015-10-16  1:45 ` Dave Chinner [this message]
2015-10-16  1:45 ` [PATCH 8/8] cleanup: Kill unnecessary xfs includes Dave Chinner
2015-10-28 11:51 ` [PATCH 0/8] xfsdump: Ouchie! My bleeding eyes! Brian Foster
2015-10-28 22:35   ` Dave Chinner
2015-10-29 12:13     ` Brian Foster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444959901-31319-8-git-send-email-david@fromorbit.com \
    --to=david@fromorbit.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.