Skip to content

Commit

Permalink
compile: add function attributes
Browse files Browse the repository at this point in the history
Some of the argument values are not in use, and few functions does not
return.  Informing which will make few warning messages disapper, and
compiler to generate better binary.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
  • Loading branch information
kerolasa authored and t8m committed Dec 21, 2012
1 parent fd2541f commit d514f00
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 7 deletions.
14 changes: 11 additions & 3 deletions Makefile.am
Expand Up @@ -8,6 +8,14 @@ pamdir = $(sysconfdir)/pam.d
dist_pam_DATA = pam/crond
endif

EXTRA_DIST = cronie.init crond.sysconfig contrib/anacrontab \
contrib/0anacron contrib/0hourly \
contrib/dailyjobs contrib/cronie.systemd
dist_noinst_HEADERS = \
cronie_common.h

EXTRA_DIST = \
cronie.init \
crond.sysconfig \
contrib/anacrontab \
contrib/0anacron \
contrib/0hourly \
contrib/dailyjobs \
contrib/cronie.systemd
37 changes: 37 additions & 0 deletions cronie_common.h
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2012 Copyright Red Hat Software
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/* Collection of definitions, inline functions, etc, that are useful for
* both cron and anacron. */

#ifndef CRONIE_COMMON_H
#define CRONIE_COMMON_H

#ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
# define __attribute__(x) /* empty */
# endif
#endif

#ifndef ATTRIBUTE_NORETURN
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
#endif

#ifndef ATTRIBUTE_UNUSED
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
#endif

#endif /* CRONIE_COMMON_H */
3 changes: 2 additions & 1 deletion src/cron.c
Expand Up @@ -48,6 +48,7 @@
# include <sys/fcntl.h>
#endif

#include "cronie_common.h"
#include "funcs.h"
#include "globals.h"
#include "pathnames.h"
Expand All @@ -60,7 +61,7 @@ int inotify_enabled;

enum timejump { negative, small, medium, large };

static void usage(void),
static void usage(void) ATTRIBUTE_NORETURN,
run_reboot_jobs(cron_db *),
find_jobs(int, cron_db *, int, int, long),
set_time(int),
Expand Down
4 changes: 3 additions & 1 deletion src/crontab.c
Expand Up @@ -56,6 +56,7 @@
# include <selinux/av_permissions.h>
#endif

#include "cronie_common.h"
#include "bitstring.h"
#include "externs.h"
#include "funcs.h"
Expand Down Expand Up @@ -101,11 +102,12 @@ static void list_cmd(void),
delete_cmd(void),
edit_cmd(void),
poke_daemon(void),
check_error(const char *), parse_args(int c, char *v[]), die(int);
check_error(const char *), parse_args(int c, char *v[]), die(int) ATTRIBUTE_NORETURN;
static int replace_cmd(void), hostset_cmd(void), hostget_cmd(void);
static char *host_specific_filename(const char *filename, int prefix);
static const char *tmp_path(void);

static void usage(const char *msg) ATTRIBUTE_NORETURN;
static void usage(const char *msg) {
fprintf(stderr, "%s: usage error: %s\n", ProgramName, msg);
fprintf(stderr, "Usage:\n");
Expand Down
8 changes: 6 additions & 2 deletions src/security.c
Expand Up @@ -29,8 +29,10 @@
#include <stdlib.h>
#include <string.h>

#include "cronie_common.h"
#include "funcs.h"
#include "globals.h"
#include "macros.h"

#ifdef WITH_PAM
# include <security/pam_appl.h>
Expand All @@ -54,7 +56,8 @@ static int pam_session_opened = 0; //global for open session

static int
cron_conv(int num_msg, const struct pam_message **msgm,
struct pam_response **response, void *appdata_ptr)
struct pam_response **response ATTRIBUTE_UNUSED,
void *appdata_ptr ATTRIBUTE_UNUSED)
{
int i;

Expand Down Expand Up @@ -103,7 +106,8 @@ void cron_restore_default_security_context() {
#endif
}

int cron_set_job_security_context(entry * e, user * u, char ***jobenv) {
int cron_set_job_security_context(entry *e, user *u ATTRIBUTE_UNUSED,
char ***jobenv) {
time_t minutely_time = 0;
#ifdef WITH_PAM
int ret;
Expand Down

0 comments on commit d514f00

Please sign in to comment.