1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

Replace GNUPG_GCC_A_ macros by GPGRT_ATTR_ macros.

* common/util.h: Provide replacement for GPGRT_ATTR_ macros when using
libgpg-error < 1.20.
* common/mischelp.h: Ditto.
* common/types.h: Ditto.
--

Given that libgpg-error is a dependency of all GnuPG related libraries
it is better to define such macros at only one place instead of having
similar macros at a lot of places.  For now we need repalcement
macros, though.
This commit is contained in:
Werner Koch 2015-07-26 12:50:16 +02:00
parent ef080d5c7f
commit d382242fb6
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
15 changed files with 88 additions and 77 deletions

View file

@ -81,11 +81,11 @@ start_new_dirmngr (assuan_context_t *r_ctx,
gpg_error_t print_assuan_status (assuan_context_t ctx,
const char *keyword,
const char *format,
...) GPGRT_GCC_A_PRINTF(3,4);
...) GPGRT_ATTR_PRINTF(3,4);
gpg_error_t vprint_assuan_status (assuan_context_t ctx,
const char *keyword,
const char *format,
va_list arg_ptr) GPGRT_GCC_A_PRINTF(3,0);
va_list arg_ptr) GPGRT_ATTR_PRINTF(3,0);
#endif /*GNUPG_COMMON_ASSHELP_H*/

View file

@ -72,11 +72,11 @@ struct audit_ctx_s
static void writeout_para (audit_ctx_t ctx,
const char *format, ...) GPGRT_GCC_A_PRINTF(2,3);
const char *format, ...) GPGRT_ATTR_PRINTF(2,3);
static void writeout_li (audit_ctx_t ctx, const char *oktext,
const char *format, ...) GPGRT_GCC_A_PRINTF(3,4);
const char *format, ...) GPGRT_ATTR_PRINTF(3,4);
static void writeout_rem (audit_ctx_t ctx,
const char *format, ...) GPGRT_GCC_A_PRINTF(2,3);
const char *format, ...) GPGRT_ATTR_PRINTF(2,3);
/* Add NAME to the list of help tags. NAME needs to be a const string

View file

@ -48,8 +48,9 @@ int log_test_fd (int fd);
int log_get_fd(void);
estream_t log_get_stream (void);
#ifdef GPGRT_GCC_M_FUNCTION
void bug_at( const char *file, int line, const char *func ) GPGRT_GCC_A_NR;
#ifdef GPGRT_HAVE_MACRO_FUNCTION
void bug_at (const char *file, int line, const char *func)
GPGRT_ATTR_NORETURN;
# define BUG() bug_at( __FILE__ , __LINE__, __FUNCTION__ )
#else
void bug_at( const char *file, int line );
@ -74,17 +75,17 @@ enum jnlib_log_levels {
GPGRT_LOG_BUG,
GPGRT_LOG_DEBUG
};
void log_log (int level, const char *fmt, ...) GPGRT_GCC_A_PRINTF(2,3);
void log_log (int level, const char *fmt, ...) GPGRT_ATTR_PRINTF(2,3);
void log_logv (int level, const char *fmt, va_list arg_ptr);
void log_string (int level, const char *string);
void log_bug( const char *fmt, ... ) GPGRT_GCC_A_NR_PRINTF(1,2);
void log_fatal( const char *fmt, ... ) GPGRT_GCC_A_NR_PRINTF(1,2);
void log_error( const char *fmt, ... ) GPGRT_GCC_A_PRINTF(1,2);
void log_info( const char *fmt, ... ) GPGRT_GCC_A_PRINTF(1,2);
void log_debug( const char *fmt, ... ) GPGRT_GCC_A_PRINTF(1,2);
void log_printf( const char *fmt, ... ) GPGRT_GCC_A_PRINTF(1,2);
void log_bug (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2);
void log_fatal (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2);
void log_error (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
void log_info (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
void log_debug (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
void log_printf (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
void log_flush (void);
/* Print a hexdump of BUFFER. With TEXT passes as NULL print just the

View file

@ -55,7 +55,7 @@ void clear_membuf (membuf_t *mb, size_t amount);
void put_membuf (membuf_t *mb, const void *buf, size_t len);
void put_membuf_str (membuf_t *mb, const char *string);
void put_membuf_printf (membuf_t *mb, const char *format,
...) GPGRT_GCC_A_PRINTF(2,3);
...) GPGRT_ATTR_PRINTF(2,3);
void *get_membuf (membuf_t *mb, size_t *len);
void *get_membuf_shrink (membuf_t *mb, size_t *len);
const void *peek_membuf (membuf_t *mb, size_t *len);

View file

@ -48,27 +48,32 @@ time_t timegm (struct tm *tm);
#define DIMof(type,member) DIM(((type *)0)->member)
#undef GPGRT_GCC_HAVE_PUSH_PRAGMA
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
# define GPGRT_GCC_M_FUNCTION 1 /* __FUNCTION__ macro is available. */
# define GPGRT_GCC_A_NR __attribute__ ((noreturn))
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4 )
# define GPGRT_GCC_HAVE_PUSH_PRAGMA 1
# define GPGRT_GCC_A_PRINTF( f, a ) \
__attribute__ ((format (__gnu_printf__,f,a)))
# define GPGRT_GCC_A_NR_PRINTF( f, a ) \
__attribute__ ((noreturn, format (__gnu_printf__,f,a)))
# else
# define GPGRT_GCC_A_PRINTF( f, a ) __attribute__ ((format (printf,f,a)))
# define GPGRT_GCC_A_NR_PRINTF( f, a ) \
__attribute__ ((noreturn, format (printf,f,a)))
# endif
#else
# define GPGRT_GCC_A_NR
# define GPGRT_GCC_A_PRINTF( f, a )
# define GPGRT_GCC_A_NR_PRINTF( f, a )
#endif
/* Replacements for macros not available with libgpg-error < 1.20. */
#ifndef GPGRT_GCC_VERSION
# undef GPGRT_HAVE_PRAGMA_GCC_PUSH
# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
# define GPGRT_HAVE_MACRO_FUNCTION 1 /* __FUNCTION__ macro is available. */
# define GPGRT_ATTR_NORETURN __attribute__ ((noreturn))
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4 )
# define GPGRT_HAVE_PRAGMA_GCC_PUSH 1
# define GPGRT_ATTR_PRINTF(f,a) \
__attribute__ ((format (__gnu_printf__,f,a)))
# define GPGRT_ATTR_NR_PRINTF(f,a) \
__attribute__ ((noreturn, format (__gnu_printf__,f,a)))
# else
# define GPGRT_ATTR_PRINTF(f, a) \
__attribute__ ((format (printf,f,a)))
# define GPGRT_ATTR_NR_PRINTF(f, a) \
__attribute__ ((noreturn, format (printf,f,a)))
# endif
# else
# define GPGRT_ATTR_NORETURN
# define GPGRT_ATTR_PRINTF( f, a )
# define GPGRT_ATTR_NR_PRINTF( f, a )
# endif
#endif /*Older libgpg-error. */
/* To avoid that a compiler optimizes certain memset calls away, these
macros may be used instead. */

View file

@ -52,11 +52,11 @@ size_t length_sans_trailing_ws (const unsigned char *line, size_t len);
char *make_basename(const char *filepath, const char *inputpath);
char *make_dirname(const char *filepath);
char *make_filename( const char *first_part, ... ) GNUPG_GCC_A_SENTINEL(0);
char *make_filename_try (const char *first_part, ... ) GNUPG_GCC_A_SENTINEL(0);
char *make_absfilename (const char *first_part, ...) GNUPG_GCC_A_SENTINEL(0);
char *make_filename( const char *first_part, ... ) GPGRT_ATTR_SENTINEL(0);
char *make_filename_try (const char *first_part, ... ) GPGRT_ATTR_SENTINEL(0);
char *make_absfilename (const char *first_part, ...) GPGRT_ATTR_SENTINEL(0);
char *make_absfilename_try (const char *first_part,
...) GNUPG_GCC_A_SENTINEL(0);
...) GPGRT_ATTR_SENTINEL(0);
int compare_filenames( const char *a, const char *b );
int hextobyte (const char *s);
@ -139,9 +139,9 @@ char *try_percent_escape (const char *str, const char *extra);
/* Concatenate the string S1 with all the following strings up to a
NULL. Returns a malloced buffer with the new string or NULL on a
malloc error or if too many arguments are given. */
char *strconcat (const char *s1, ...) GNUPG_GCC_A_SENTINEL(0);
char *strconcat (const char *s1, ...) GPGRT_ATTR_SENTINEL(0);
/* Ditto, but die on error. */
char *xstrconcat (const char *s1, ...) GNUPG_GCC_A_SENTINEL(0);
char *xstrconcat (const char *s1, ...) GPGRT_ATTR_SENTINEL(0);
char **strsplit (char *string, char delim, char replacement, int *count);

View file

@ -114,13 +114,13 @@
#endif
/* Some GCC attributes. Note that we use also define some in
mischelp.h, but this header and types.h are not always included.
Should eventually be put into one file (e.g. nlib-common.h). */
#if __GNUC__ >= 4
# define GNUPG_GCC_A_SENTINEL(a) __attribute__ ((sentinel(a)))
#else
# define GNUPG_GCC_A_SENTINEL(a)
/* Some GCC attributes. These are replacements for libgpg-error < 1.20. */
#ifndef GPGRT_GCC_VERSION
# if __GNUC__ >= 4
# define GPGRT_ATTR_SENTINEL(a) __attribute__ ((sentinel(a)))
# else
# define GPGRT_ATTR_SENTINEL(a)
# endif
#endif
#endif /*GNUPG_COMMON_TYPES_H*/

View file

@ -152,26 +152,30 @@
#define snprintf gpgrt_snprintf
/* GCC attributes. */
#ifndef GNUPG_GCC_ATTR_FORMAT_ARG
#if __GNUC__ >= 3 /* Actually 2.8 but testing the major is easier. */
# define GNUPG_GCC_ATTR_FORMAT_ARG(a) __attribute__ ((__format_arg__ (a)))
#else
# define GNUPG_GCC_ATTR_FORMAT_ARG(a)
#endif
#endif
/* Replacements for macros not available with libgpg-error < 1.20. */
#ifndef GPGRT_GCC_VERSION
#if __GNUC__ >= 4
# define GNUPG_GCC_A_SENTINEL(a) __attribute__ ((sentinel(a)))
#else
# define GNUPG_GCC_A_SENTINEL(a)
#endif
# ifndef GPGRT_ATTR_FORMAT_ARG
# if __GNUC__ >= 3 /* Actually 2.8 but testing the major is easier. */
# define GPGRT_ATTR_FORMAT_ARG(a) __attribute__ ((__format_arg__ (a)))
# else
# define GPGRT_ATTR_FORMAT_ARG(a)
# endif
# endif
#if __GNUC__ >= 4
# define GNUPG_GCC_A_USED __attribute__ ((used))
#else
# define GNUPG_GCC_A_USED
#endif
# if __GNUC__ >= 4
# define GPGRT_ATTR_SENTINEL(a) __attribute__ ((sentinel(a)))
# else
# define GPGRT_ATTR_SENTINEL(a)
# endif
# if __GNUC__ >= 4
# define GPGRT_ATTR_USED __attribute__ ((used))
# else
# define GPGRT_ATTR_USED
# endif
#endif /*libgpg-error < 1.20 */
/* We need this type even if we are not using libreadline and or we
@ -371,9 +375,9 @@ const char *gnupg_messages_locale_name (void);
void setup_libgcrypt_logging (void);
/* Same as estream_asprintf but die on memory failure. */
char *xasprintf (const char *fmt, ...) GPGRT_GCC_A_PRINTF(1,2);
char *xasprintf (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
/* This is now an alias to estream_asprintf. */
char *xtryasprintf (const char *fmt, ...) GPGRT_GCC_A_PRINTF(1,2);
char *xtryasprintf (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
/* Replacement for gcry_cipher_algo_name. */
const char *gnupg_cipher_algo_name (int algo);