Skip to content

Commit

Permalink
Replace the rest of the uses of __attribute__ that need to be portabl…
Browse files Browse the repository at this point in the history
…e (Issue #5349)
  • Loading branch information
michaelrsweet committed Jul 9, 2018
1 parent be3b49a commit a32af27
Show file tree
Hide file tree
Showing 25 changed files with 221 additions and 114 deletions.
40 changes: 6 additions & 34 deletions backend/dnssd.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,8 @@ static int browsers = 0; /* Number of running browsers */
*/

#ifdef HAVE_DNSSD
static void browse_callback(DNSServiceRef sdRef,
DNSServiceFlags flags,
uint32_t interfaceIndex,
DNSServiceErrorType errorCode,
const char *serviceName,
const char *regtype,
const char *replyDomain, void *context)
__attribute__((nonnull(1,5,6,7,8)));
static void browse_local_callback(DNSServiceRef sdRef,
DNSServiceFlags flags,
uint32_t interfaceIndex,
DNSServiceErrorType errorCode,
const char *serviceName,
const char *regtype,
const char *replyDomain,
void *context)
__attribute__((nonnull(1,5,6,7,8)));
static void browse_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *serviceName, const char *regtype, const char *replyDomain, void *context) _CUPS_NONNULL(1,5,6,7,8);
static void browse_local_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *serviceName, const char *regtype, const char *replyDomain, void *context) _CUPS_NONNULL(1,5,6,7,8);
#endif /* HAVE_DNSSD */
#ifdef HAVE_AVAHI
static void browse_callback(AvahiServiceBrowser *browser,
Expand All @@ -116,22 +101,10 @@ static void client_callback(AvahiClient *client,
#endif /* HAVE_AVAHI */

static int compare_devices(cups_device_t *a, cups_device_t *b);
static void exec_backend(char **argv) __attribute__((noreturn));
static cups_device_t *get_device(cups_array_t *devices,
const char *serviceName,
const char *regtype,
const char *replyDomain)
__attribute__((nonnull(1,2,3,4)));
static void exec_backend(char **argv) _CUPS_NORETURN;
static cups_device_t *get_device(cups_array_t *devices, const char *serviceName, const char *regtype, const char *replyDomain) _CUPS_NONNULL(1,2,3,4);
#ifdef HAVE_DNSSD
static void query_callback(DNSServiceRef sdRef,
DNSServiceFlags flags,
uint32_t interfaceIndex,
DNSServiceErrorType errorCode,
const char *fullName, uint16_t rrtype,
uint16_t rrclass, uint16_t rdlen,
const void *rdata, uint32_t ttl,
void *context)
__attribute__((nonnull(1,5,9,11)));
static void query_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *fullName, uint16_t rrtype, uint16_t rrclass, uint16_t rdlen, const void *rdata, uint32_t ttl, void *context) _CUPS_NONNULL(1,5,9,11);
#elif defined(HAVE_AVAHI)
static int poll_callback(struct pollfd *pollfds,
unsigned int num_pollfds, int timeout,
Expand All @@ -147,8 +120,7 @@ static void query_callback(AvahiRecordBrowser *browser,
void *context);
#endif /* HAVE_DNSSD */
static void sigterm_handler(int sig);
static void unquote(char *dst, const char *src, size_t dstsize)
__attribute__((nonnull(1,2)));
static void unquote(char *dst, const char *src, size_t dstsize) _CUPS_NONNULL(1,2);


/*
Expand Down
2 changes: 1 addition & 1 deletion backend/testbackend.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static int job_canceled = 0;
*/

static void sigterm_handler(int sig);
static void usage(void) __attribute__((noreturn));
static void usage(void) _CUPS_NORETURN;
static void walk_cb(const char *oid, const char *data, int datalen,
void *context);

Expand Down
4 changes: 2 additions & 2 deletions backend/usb-darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@ static void status_timer_cb(CFRunLoopTimerRef timer, void *info);

#if defined(__i386__) || defined(__x86_64__)
static pid_t child_pid; /* Child PID */
static void run_legacy_backend(int argc, char *argv[], int fd) __attribute__((noreturn)); /* Starts child backend process running as a ppc executable */
static void run_legacy_backend(int argc, char *argv[], int fd) _CUPS_NORETURN; /* Starts child backend process running as a ppc executable */
#endif /* __i386__ || __x86_64__ */
static void sigterm_handler(int sig); /* SIGTERM handler */
static void sigquit_handler(int sig, siginfo_t *si, void *unused) __attribute__((noreturn));
static void sigquit_handler(int sig, siginfo_t *si, void *unused) _CUPS_NORETURN;

#ifdef PARSE_PS_ERRORS
static const char *next_line (const char *buffer);
Expand Down
2 changes: 1 addition & 1 deletion berkeley/lpq.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static http_t *connect_server(const char *, http_t *);
static int show_jobs(const char *, http_t *, const char *,
const char *, const int, const int);
static void show_printer(const char *, http_t *, const char *);
static void usage(void) __attribute__((noreturn));
static void usage(void) _CUPS_NORETURN;


/*
Expand Down
6 changes: 1 addition & 5 deletions cgi-bin/help-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,7 @@ static int help_load_file(help_index_t *hi,
const char *filename,
const char *relative,
time_t mtime);
static help_node_t *help_new_node(const char *filename, const char *anchor,
const char *section, const char *text,
time_t mtime, off_t offset,
size_t length)
__attribute__((nonnull(1,3,4)));
static help_node_t *help_new_node(const char *filename, const char *anchor, const char *section, const char *text, time_t mtime, off_t offset, size_t length) _CUPS_NONNULL(1,3,4);
static int help_sort_by_name(help_node_t *p1, help_node_t *p2);
static int help_sort_by_score(help_node_t *p1, help_node_t *p2);
static int help_sort_words(help_word_t *w1, help_word_t *w2);
Expand Down
8 changes: 2 additions & 6 deletions cups/ipp.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@ static ipp_attribute_t *ipp_add_attr(ipp_t *ipp, const char *name,
int num_values);
static void ipp_free_values(ipp_attribute_t *attr, int element,
int count);
static char *ipp_get_code(const char *locale, char *buffer,
size_t bufsize)
__attribute__((nonnull(1,2)));
static char *ipp_lang_code(const char *locale, char *buffer,
size_t bufsize)
__attribute__((nonnull(1,2)));
static char *ipp_get_code(const char *locale, char *buffer, size_t bufsize) _CUPS_NONNULL(1,2);
static char *ipp_lang_code(const char *locale, char *buffer, size_t bufsize) _CUPS_NONNULL(1,2);
static size_t ipp_length(ipp_t *ipp, int collection);
static ssize_t ipp_read_http(http_t *http, ipp_uchar_t *buffer,
size_t length);
Expand Down
2 changes: 1 addition & 1 deletion cups/testdest.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static void show_conflicts(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo,
static void show_default(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *option);
static void show_media(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags, const char *name);
static void show_supported(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *option, const char *value);
static void usage(const char *arg) __attribute__((noreturn));
static void usage(const char *arg) _CUPS_NORETURN;


/*
Expand Down
2 changes: 1 addition & 1 deletion cups/testsnmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
static void print_packet(cups_snmp_t *packet, void *data);
static int show_oid(int fd, const char *community,
http_addr_t *addr, const char *s, int walk);
static void usage(void) __attribute__((noreturn));
static void usage(void) _CUPS_NORETURN;


/*
Expand Down
14 changes: 14 additions & 0 deletions cups/versioning.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* - _CUPS_INTERNAL_MSG("msg"): Function is
* - _CUPS_NONNULL((arg list)): Specifies the comma-separated argument indices
* are assumed non-NULL. Indices start at 1.
* - _CUPS_NORETURN: Specifies the function does not return.
* - _CUPS_PRIVATE: Specifies the function is private to CUPS.
* - _CUPS_PUBLIC: Specifies the function is public API.
*/
Expand All @@ -41,6 +42,7 @@
# ifdef __has_extension /* Clang */
# define _CUPS_HAS_DEPRECATED
# define _CUPS_HAS_FORMAT
# define _CUPS_HAS_NORETURN
# define _CUPS_HAS_VISIBILITY
# if __has_extension(attribute_deprecated_with_message)
# define _CUPS_HAS_DEPRECATED_WITH_MESSAGE
Expand All @@ -52,6 +54,7 @@
# if __GNUC__ >= 3 /* GCC 3.0 or higher */
# define _CUPS_HAS_DEPRECATED
# define _CUPS_HAS_FORMAT
# define _CUPS_HAS_NORETURN
# define _CUPS_HAS_VISIBILITY
# endif /* __GNUC__ >= 3 */
# if __GNUC__ >= 5 /* GCC 5.x */
Expand Down Expand Up @@ -231,4 +234,15 @@
# endif /* _CUPS_HAS_FORMAT */


/*
* Define _CUPS_NORETURN macro for functions that don't return.
*/

# ifdef _CUPS_HAS_NORETURN
# define _CUPS_NORETURN __attribute__ ((noreturn))
# else
# define _CUPS_NORETURN
# endif /* _CUPS_HAS_NORETURN */


#endif /* !_CUPS_VERSIONING_H_ */
3 changes: 1 addition & 2 deletions filter/pstops.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ static ssize_t copy_trailer(cups_file_t *fp, pstops_doc_t *doc,
ssize_t linelen, size_t linesize);
static void do_prolog(pstops_doc_t *doc, ppd_file_t *ppd);
static void do_setup(pstops_doc_t *doc, ppd_file_t *ppd);
static void doc_printf(pstops_doc_t *doc, const char *format, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
static void doc_printf(pstops_doc_t *doc, const char *format, ...) _CUPS_FORMAT(2, 3);
static void doc_puts(pstops_doc_t *doc, const char *s);
static void doc_write(pstops_doc_t *doc, const char *s, size_t len);
static void end_nup(pstops_doc_t *doc, int number);
Expand Down
2 changes: 1 addition & 1 deletion scheduler/cups-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* Local functions...
*/

static void usage(void) __attribute__((noreturn));
static void usage(void) _CUPS_NORETURN;


/*
Expand Down
2 changes: 1 addition & 1 deletion scheduler/cupsfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int open_pipe(int *fds);
static int read_cups_files_conf(const char *filename);
static void set_string(char **s, const char *val);
static void sighandler(int sig);
static void usage(const char *opt) __attribute__((noreturn));
static void usage(const char *opt) _CUPS_NORETURN;


/*
Expand Down
4 changes: 1 addition & 3 deletions scheduler/ipp.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ static void save_auth_info(cupsd_client_t *con, cupsd_job_t *job,
static void send_document(cupsd_client_t *con, ipp_attribute_t *uri);
static void send_http_error(cupsd_client_t *con, http_status_t status,
cupsd_printer_t *printer);
static void send_ipp_status(cupsd_client_t *con, ipp_status_t status,
const char *message, ...)
__attribute__((__format__(__printf__, 3, 4)));
static void send_ipp_status(cupsd_client_t *con, ipp_status_t status, const char *message, ...) _CUPS_FORMAT(3, 4);
static void set_default(cupsd_client_t *con, ipp_attribute_t *uri);
static void set_job_attrs(cupsd_client_t *con, ipp_attribute_t *uri);
static void set_printer_attrs(cupsd_client_t *con, ipp_attribute_t *uri);
Expand Down
2 changes: 1 addition & 1 deletion scheduler/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static void sigterm_handler(int sig);
static long select_timeout(int fds);
static void service_checkin(void);
static void service_checkout(int shutdown);
static void usage(int status) __attribute__((noreturn));
static void usage(int status) _CUPS_NORETURN;


/*
Expand Down
10 changes: 5 additions & 5 deletions scheduler/testlpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
*/

static int do_command(int outfd, int infd, const char *command);
static int print_job(int outfd, int infd, char *dest, char **args) __attribute__((nonnull(4)));
static int print_job(int outfd, int infd, char *dest, char **args) _CUPS_NONNULL(4);
static int print_waiting(int outfd, int infd, char *dest);
static int remove_job(int outfd, int infd, char *dest, char **args) __attribute__((nonnull(4)));
static int status_long(int outfd, int infd, char *dest, char **args) __attribute__((nonnull(4)));
static int status_short(int outfd, int infd, char *dest, char **args) __attribute__((nonnull(4)));
static void usage(void) __attribute__((noreturn));
static int remove_job(int outfd, int infd, char *dest, char **args) _CUPS_NONNULL(4);
static int status_long(int outfd, int infd, char *dest, char **args) _CUPS_NONNULL(4);
static int status_short(int outfd, int infd, char *dest, char **args) _CUPS_NONNULL(4);
static void usage(void) _CUPS_NORETURN;


/*
Expand Down
2 changes: 1 addition & 1 deletion scheduler/testspeed.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
static int do_test(const char *server, int port,
http_encryption_t encryption, int requests,
const char *opstring, int verbose);
static void usage(void) __attribute__((noreturn));
static void usage(void) _CUPS_NORETURN;


/*
Expand Down
2 changes: 1 addition & 1 deletion scheduler/testsub.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static int terminate = 0;

static void print_attributes(ipp_t *ipp, int indent);
static void sigterm_handler(int sig);
static void usage(void) __attribute__((noreturn));
static void usage(void) _CUPS_NORETURN;


/*
Expand Down
2 changes: 1 addition & 1 deletion systemv/cupsaddsmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const char *SAMBAUser,
*/

int export_dest(http_t *http, const char *dest);
void usage(void) __attribute__((noreturn));
void usage(void) _CUPS_NORETURN;


/*
Expand Down
2 changes: 1 addition & 1 deletion systemv/cupsctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Local functions...
*/

static void usage(const char *opt) __attribute__((noreturn));
static void usage(const char *opt) _CUPS_NORETURN;


/*
Expand Down
2 changes: 1 addition & 1 deletion systemv/cupstestdsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

static int check_file(const char *filename);
static void usage(void) __attribute__((noreturn));
static void usage(void) _CUPS_NORETURN;


/*
Expand Down
2 changes: 1 addition & 1 deletion systemv/cupstestppd.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static int check_translations(ppd_file_t *ppd, int errors, int verbose,
int warn);
static void show_conflicts(ppd_file_t *ppd, const char *prefix);
static int test_raster(ppd_file_t *ppd, int verbose);
static void usage(void) __attribute__((noreturn));
static void usage(void) _CUPS_NORETURN;
static int valid_path(const char *keyword, const char *path, int errors,
int verbose, int warn);
static int valid_utf8(const char *s);
Expand Down
2 changes: 1 addition & 1 deletion systemv/lpoptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

static void list_group(ppd_file_t *ppd, ppd_group_t *group);
static void list_options(cups_dest_t *dest);
static void usage(void) __attribute__((noreturn));
static void usage(void) _CUPS_NORETURN;


/*
Expand Down
40 changes: 6 additions & 34 deletions test/ippfind.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,8 @@ static int ipp_version = 20; /* IPP version for LIST */
*/

#ifdef HAVE_DNSSD
static void DNSSD_API browse_callback(DNSServiceRef sdRef,
DNSServiceFlags flags,
uint32_t interfaceIndex,
DNSServiceErrorType errorCode,
const char *serviceName,
const char *regtype,
const char *replyDomain, void *context)
__attribute__((nonnull(1,5,6,7,8)));
static void DNSSD_API browse_local_callback(DNSServiceRef sdRef,
DNSServiceFlags flags,
uint32_t interfaceIndex,
DNSServiceErrorType errorCode,
const char *serviceName,
const char *regtype,
const char *replyDomain,
void *context)
__attribute__((nonnull(1,5,6,7,8)));
static void DNSSD_API browse_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *serviceName, const char *regtype, const char *replyDomain, void *context) _CUPS_NONNULL(1,5,6,7,8);
static void DNSSD_API browse_local_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *serviceName, const char *regtype, const char *replyDomain, void *context) _CUPS_NONNULL(1,5,6,7,8);
#elif defined(HAVE_AVAHI)
static void browse_callback(AvahiServiceBrowser *browser,
AvahiIfIndex interface,
Expand All @@ -182,27 +167,14 @@ static int eval_expr(ippfind_srv_t *service,
ippfind_expr_t *expressions);
static int exec_program(ippfind_srv_t *service, int num_args,
char **args);
static ippfind_srv_t *get_service(cups_array_t *services,
const char *serviceName,
const char *regtype,
const char *replyDomain)
__attribute__((nonnull(1,2,3,4)));
static ippfind_srv_t *get_service(cups_array_t *services, const char *serviceName, const char *regtype, const char *replyDomain) _CUPS_NONNULL(1,2,3,4);
static double get_time(void);
static int list_service(ippfind_srv_t *service);
static ippfind_expr_t *new_expr(ippfind_op_t op, int invert,
const char *value, const char *regex,
char **args);
#ifdef HAVE_DNSSD
static void DNSSD_API resolve_callback(DNSServiceRef sdRef,
DNSServiceFlags flags,
uint32_t interfaceIndex,
DNSServiceErrorType errorCode,
const char *fullName,
const char *hostTarget, uint16_t port,
uint16_t txtLen,
const unsigned char *txtRecord,
void *context)
__attribute__((nonnull(1,5,6,9, 10)));
static void DNSSD_API resolve_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *fullName, const char *hostTarget, uint16_t port, uint16_t txtLen, const unsigned char *txtRecord, void *context) _CUPS_NONNULL(1,5,6,9, 10);
#elif defined(HAVE_AVAHI)
static int poll_callback(struct pollfd *pollfds,
unsigned int num_pollfds, int timeout,
Expand All @@ -222,8 +194,8 @@ static void resolve_callback(AvahiServiceResolver *res,
void *context);
#endif /* HAVE_DNSSD */
static void set_service_uri(ippfind_srv_t *service);
static void show_usage(void) __attribute__((noreturn));
static void show_version(void) __attribute__((noreturn));
static void show_usage(void) _CUPS_NORETURN;
static void show_version(void) _CUPS_NORETURN;


/*
Expand Down
Loading

0 comments on commit a32af27

Please sign in to comment.