Author: jelmer Date: 2007-06-01 12:01:53 +0000 (Fri, 01 Jun 2007) New Revision: 23289
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23289 Log: Provide support for GCC attributes _PURE_, _NONNULL_, _DEPRECATED_, _NORETURN_ and _WARN_UNUSED_RESULT_. Modified: branches/SAMBA_4_0/ branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_util.c branches/SAMBA_4_0/source/include/includes.h branches/SAMBA_4_0/source/lib/json/debug.c branches/SAMBA_4_0/source/lib/json/linkhash.c branches/SAMBA_4_0/source/lib/util/fault.c branches/SAMBA_4_0/source/lib/util/util_str.c branches/SAMBA_4_0/source/script/mkproto.pl Changeset: Property changes on: branches/SAMBA_4_0 ___________________________________________________________________ Name: bzr:revision-info - timestamp: Mon 2007-05-28 23:02:10.542000055 +0200 committer: Jelmer Vernooij <[EMAIL PROTECTED]> properties: branch-nick: SAMBA_4_0 + timestamp: Fri 2007-06-01 13:45:21.213999987 +0200 committer: Jelmer Vernooij <[EMAIL PROTECTED]> properties: branch-nick: SAMBA_4_0 Name: bzr:revision-id-v3 - [EMAIL PROTECTED] [EMAIL PROTECTED] + [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] Name: bzr:merge ...skipped... Modified: branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_util.c =================================================================== --- branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_util.c 2007-06-01 10:17:02 UTC (rev 23288) +++ branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_util.c 2007-06-01 12:01:53 UTC (rev 23289) @@ -52,7 +52,7 @@ /* a fatal internal error occurred - no hope for recovery */ -void ctdb_fatal(struct ctdb_context *ctdb, const char *msg) +_NORETURN_ void ctdb_fatal(struct ctdb_context *ctdb, const char *msg) { DEBUG(0,("ctdb fatal error: %s\n", msg)); fprintf(stderr, "ctdb fatal error: '%s'\n", msg); Modified: branches/SAMBA_4_0/source/include/includes.h =================================================================== --- branches/SAMBA_4_0/source/include/includes.h 2007-06-01 10:17:02 UTC (rev 23288) +++ branches/SAMBA_4_0/source/include/includes.h 2007-06-01 12:01:53 UTC (rev 23289) @@ -62,18 +62,46 @@ #endif #endif -#ifndef NORETURN_ATTRIBUTE -#if (__GNUC__ >= 3) -#define NORETURN_ATTRIBUTE __attribute__ ((noreturn)) +#ifndef _DEPRECATED_ +#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) +#define _DEPRECATED_ __attribute__ ((deprecated)) #else -#define NORETURN_ATTRIBUTE +#define _DEPRECATED_ #endif #endif -/* mark smb_panic() as noreturn, so static analysers know that it is - used like abort */ -_PUBLIC_ void smb_panic(const char *why) NORETURN_ATTRIBUTE; +#ifndef _WARN_UNUSED_RESULT_ +#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) +#define _WARN_UNUSED_RESULT_ __attribute__ ((warn_unused_result)) +#else +#define _WARN_UNUSED_RESULT_ +#endif +#endif +#ifndef _NORETURN_ +#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) +#define _NORETURN_ __attribute__ ((noreturn)) +#else +#define _NORETURN_ +#endif +#endif + +#ifndef _PURE_ +#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1) +#define _PURE_ __attribute__((pure)) +#else +#define _PURE_ +#endif +#endif + +#ifndef NONNULL +#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1) +#define NONNULL(param) param __attribute__((nonnull)) +#else +#define NONNULL(param) param +#endif +#endif + #include "system/time.h" #include "system/wait.h" Modified: branches/SAMBA_4_0/source/lib/json/debug.c =================================================================== --- branches/SAMBA_4_0/source/lib/json/debug.c 2007-06-01 10:17:02 UTC (rev 23288) +++ branches/SAMBA_4_0/source/lib/json/debug.c 2007-06-01 12:01:53 UTC (rev 23289) @@ -41,7 +41,7 @@ _syslog = syslog; } -void mc_abort(const char *msg, ...) +_NORETURN_ void mc_abort(const char *msg, ...) { va_list ap; va_start(ap, msg); Modified: branches/SAMBA_4_0/source/lib/json/linkhash.c =================================================================== --- branches/SAMBA_4_0/source/lib/json/linkhash.c 2007-06-01 10:17:02 UTC (rev 23288) +++ branches/SAMBA_4_0/source/lib/json/linkhash.c 2007-06-01 12:01:53 UTC (rev 23289) @@ -20,7 +20,7 @@ #include "linkhash.h" -void lh_abort(const char *msg, ...) +_NORETURN_ void lh_abort(const char *msg, ...) { va_list ap; va_start(ap, msg); Modified: branches/SAMBA_4_0/source/lib/util/fault.c =================================================================== --- branches/SAMBA_4_0/source/lib/util/fault.c 2007-06-01 10:17:02 UTC (rev 23288) +++ branches/SAMBA_4_0/source/lib/util/fault.c 2007-06-01 12:01:53 UTC (rev 23289) @@ -118,7 +118,7 @@ /** Something really nasty happened - panic ! **/ -_PUBLIC_ void smb_panic(const char *why) +_PUBLIC_ _NORETURN_ void smb_panic(const char *why) { int result; Modified: branches/SAMBA_4_0/source/lib/util/util_str.c =================================================================== --- branches/SAMBA_4_0/source/lib/util/util_str.c 2007-06-01 10:17:02 UTC (rev 23288) +++ branches/SAMBA_4_0/source/lib/util/util_str.c 2007-06-01 12:01:53 UTC (rev 23289) @@ -36,16 +36,16 @@ /** Trim the specified elements off the front and back of a string. **/ -_PUBLIC_ BOOL trim_string(char *s,const char *front,const char *back) +_PUBLIC_ bool trim_string(char *s, const char *front, const char *back) { - BOOL ret = False; + bool ret = false; size_t front_len; size_t back_len; size_t len; /* Ignore null or empty strings. */ if (!s || (s[0] == '\0')) - return False; + return false; front_len = front? strlen(front) : 0; back_len = back? strlen(back) : 0; @@ -58,7 +58,7 @@ * easily overlap. Found by valgrind. JRA. */ memmove(s, s+front_len, (len-front_len)+1); len -= front_len; - ret=True; + ret=true; } } @@ -66,7 +66,7 @@ while ((len >= back_len) && strncmp(s+len-back_len,back,back_len)==0) { s[len-back_len]='\0'; len -= back_len; - ret=True; + ret=true; } } return ret; @@ -75,7 +75,7 @@ /** Find the number of 'c' chars in a string **/ -_PUBLIC_ size_t count_chars(const char *s, char c) +_PUBLIC_ _PURE_ size_t count_chars(const char *s, char c) { size_t count = 0; @@ -218,7 +218,7 @@ /** * Parse a hex string and return a data blob. */ -_PUBLIC_ DATA_BLOB strhex_to_data_blob(const char *strhex) +_PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(const char *strhex) { DATA_BLOB ret_blob = data_blob(NULL, strlen(strhex)/2+1); Modified: branches/SAMBA_4_0/source/script/mkproto.pl =================================================================== --- branches/SAMBA_4_0/source/script/mkproto.pl 2007-06-01 10:17:02 UTC (rev 23288) +++ branches/SAMBA_4_0/source/script/mkproto.pl 2007-06-01 12:01:53 UTC (rev 23289) @@ -180,7 +180,8 @@ } next unless ( $is_public || $line =~ / - (_DEPRECATED_ )?^(void|BOOL|bool|int|struct|char|const|\w+_[tT]\s|uint|unsigned|long|NTSTATUS| + (_DEPRECATED_ |_NORETURN_ |_WARN_UNUSED_RESULT_ |_PURE_ )*^( + void|BOOL|bool|int|struct|char|const|\w+_[tT]\s|uint|unsigned|long|NTSTATUS| ADS_STATUS|enum\s.*\(|DATA_BLOB|WERROR|XFILE|FILE|DIR| double|TDB_CONTEXT|TDB_DATA|TALLOC_CTX|NTTIME|FN_|init_module| GtkWidget|GType|smb_ucs2_t|krb5_error_code) @@ -224,6 +225,10 @@ } public("#ifndef _PUBLIC_\n#define _PUBLIC_\n#endif\n\n"); +public("#ifndef _PURE_\n#define _PURE_\n#endif\n\n"); +public("#ifndef _NORETURN_\n#define _NORETURN_\n#endif\n\n"); +public("#ifndef _DEPRECATED_\n#define _DEPRECATED_\n#endif\n\n"); +public("#ifndef _WARN_UNUSED_RESULT_\n#define _WARN_UNUSED_RESULT_\n#endif\n\n"); process_file(\&public, \&private, $_) foreach (@ARGV); print_footer(\&public, $public_define);