diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2012-12-22 22:38:26 +0100 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2012-12-22 22:38:26 +0100 |
commit | c7bb19c55c7a902e25bdd33b0d49a2ddcf62e07a (patch) | |
tree | b3a75ef2719bc2f334041460fd21fbdf86a23a82 /tests/common.h | |
parent | d336cd6b429f8ce40c58ea287f79bbc7c23d0966 (diff) |
update C coding style to a more commonly used style
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1873 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'tests/common.h')
-rw-r--r-- | tests/common.h | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/tests/common.h b/tests/common.h index 1c0b96e..500f740 100644 --- a/tests/common.h +++ b/tests/common.h @@ -33,42 +33,45 @@ #ifndef HAVE___ASSERT_FAIL /* for Solaris: */ #ifdef sun -#define __assert_fail(assertion,file,line,function) __assert(assertion,file,line) +#define __assert_fail(assertion, file, line, function) \ + __assert(assertion, file, line) #endif /* for FreeBSD: */ #ifdef __FreeBSD__ -#define __assert_fail(assertion,file,line,function) __assert(assertion,file,line,function) +#define __assert_fail(assertion, file, line, function) \ + __assert(assertion, file, line, function) #endif #endif /* not HAVE___ASSERT_FAIL */ /* extra assertion function that epxects both strings to be the same (special macro because strcmp() can be a macro that turns ugly in assert) */ -#define assertstreq(str1,str2) \ - (assertstreq_impl(str1,str2,"strcmp(" __STRING(str1) "," __STRING(str2) ")==0", \ +#define assertstreq(str1, str2) \ + (assertstreq_impl(str1, str2, \ + "strcmp(" __STRING(str1) ", " __STRING(str2) ") == 0", \ __FILE__, __LINE__, __ASSERT_FUNCTION)) -static inline void assertstreq_impl(const char *str1,const char *str2, - const char *assertion,const char *file, - int line,const char *function) +static inline void assertstreq_impl(const char *str1, const char *str2, + const char *assertion, const char *file, + int line, const char *function) { - if (strcmp(str1,str2)!=0) - __assert_fail(assertion,file,line,function); + if (strcmp(str1, str2) != 0) + __assert_fail(assertion, file, line, function); } /* extra assertion function that expects expr to be valid and prints an error message that include errno otherwise */ -#define assertok(expr) \ - ((expr) \ - ? (void) (0) \ - : __assertok_fail(__STRING(expr),__FILE__,__LINE__,__ASSERT_FUNCTION)) +#define assertok(expr) \ + ((expr) \ + ? (void) (0) \ + : __assertok_fail(__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION)) -static inline void __assertok_fail(const char *expr,const char *file, - int line,const char *function) +static inline void __assertok_fail(const char *expr, const char *file, + int line, const char *function) { char msg[120]; - snprintf(msg,sizeof(msg),"%s (errno=\"%s\")",expr,strerror(errno)); - __assert_fail(msg,file,line,function); + snprintf(msg, sizeof(msg), "%s (errno=\"%s\")", expr, strerror(errno)); + __assert_fail(msg, file, line, function); } |