]> granicus.if.org Git - cronie/commitdiff
compile: add function attributes
authorSami Kerola <kerolasa@iki.fi>
Sat, 1 Dec 2012 17:35:40 +0000 (17:35 +0000)
committerTomas Mraz <tmraz@fedoraproject.org>
Fri, 21 Dec 2012 20:32:29 +0000 (21:32 +0100)
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>
Makefile.am
cronie_common.h [new file with mode: 0644]
src/cron.c
src/crontab.c
src/security.c

index abbce4a257d35dd6d84e7b88449f607f768a8a44..58ecaacba46999e521e7c3a71093757bcdc2e40f 100644 (file)
@@ -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
diff --git a/cronie_common.h b/cronie_common.h
new file mode 100644 (file)
index 0000000..4ce172e
--- /dev/null
@@ -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 */
index a79806e51ff88f36d36cdb8c4877849f601eac2e..997488703bdacceb6dbe547335c86f020f172ccd 100644 (file)
@@ -48,6 +48,7 @@
 # include <sys/fcntl.h>
 #endif
 
+#include "cronie_common.h"
 #include "funcs.h"
 #include "globals.h"
 #include "pathnames.h"
@@ -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),
index 0e4c851cba041bf3bd15af8ff27786d118d61e83..bfff1827d337c0dba88953841632103e95234804 100644 (file)
@@ -56,6 +56,7 @@
 # include <selinux/av_permissions.h>
 #endif
 
+#include "cronie_common.h"
 #include "bitstring.h"
 #include "externs.h"
 #include "funcs.h"
@@ -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");
index 7639891889f50e4954a7db117f9c63d2927b1393..b483134844eab7bf7f68172d083221e595292042 100644 (file)
 #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>
@@ -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;
 
@@ -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;