~ubuntu-branches/ubuntu/trusty/ntp/trusty-proposed

« back to all changes in this revision

Viewing changes to include/ntp_assert.h

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-04-03 07:21:01 UTC
  • mfrom: (4.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20130403072101-v3vt8xcs18b6uhjf
Tags: 1:4.2.6.p5+dfsg-2ubuntu1
* New upstream version, fixing build failure in raring.
* Merge with Debian; remaining changes:
  + debian/ntp.conf, debian/ntpdate.default: Change default server to
    ntp.ubuntu.com.
  + debian/ntpdate.ifup: Stop ntp before running ntpdate when an interface
    comes up, then start again afterwards.
  + debian/ntp.init, debian/rules: Only stop when entering single user mode.
  + Add enforcing AppArmor profile:
    - debian/control: Add Conflicts/Replaces on apparmor-profiles.
    - debian/control: Add Suggests on apparmor.
    - debian/ntp.dirs: Add apparmor directories.
    - debian/ntp.preinst: Force complain on certain upgrades.
    - debian/ntp.postinst: Reload apparmor profile.
    - debian/ntp.postrm: Remove the force-complain file.
    - add debian/apparmor-profile*.
    - debian/rules: install apparmor-profile and apparmor-profile.tunable.
    - debian/README.Debian: Add note on AppArmor.
  + debian/{control,rules}: Add and enable hardened build for PIE.
  + debian/apparmor-profile: Adjust location of drift files.
  + debian/rules, debian/ntp.dirs, debian/source_ntp.py: Add apport hook.
  + debian/ntpdate-debian: Disregard empty ntp.conf files.
  + debian/ntp.preinst: Remove empty /etc/ntp.conf on fresh intallation.
  + debian/ntpdate.ifup: Fix interaction with openntpd.
  + debian/source_ntp.py: Add filter on AppArmor profile names to prevent
    false positives from denials originating in other packages.
  + debian/apparmor-profile: Add samba4 ntp signing socket to ntpd apparmor
    profile.
  + debian/apparmor-profile: adjust for IPv6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 *      int result;
8
8
 *      int value;
9
9
 *
10
 
 *      NTP_REQUIRE(a != NULL);
 
10
 *      REQUIRE(a != NULL);
11
11
 *      ...
12
12
 *      bar(&value);
13
 
 *      NTP_INSIST(value > 2);
 
13
 *      INSIST(value > 2);
14
14
 *      ...
15
15
 *
16
 
 *      NTP_ENSURE(result != 12);
 
16
 *      ENSURE(result != 12);
17
17
 *      return result;
18
18
 * }
19
19
 *
20
 
 * open question: when would we use NTP_INVARIANT()?
 
20
 * open question: when would we use INVARIANT()?
 
21
 *
 
22
 * For cases where the overhead for non-debug builds is deemed too high,
 
23
 * use DEBUG_REQUIRE(), DEBUG_INSIST(), DEBUG_ENSURE(), and/or
 
24
 * DEBUG_INVARIANT().
21
25
 */
22
26
 
23
27
#ifndef NTP_ASSERT_H
27
31
 
28
32
extern void calysto_assume(unsigned char cnd); /* assume this always holds */ 
29
33
extern void calysto_assert(unsigned char cnd); /* check whether this holds */ 
30
 
#define NTP_REQUIRE(x)          calysto_assert(x)
31
 
#define NTP_INSIST(x)           calysto_assume(x) /* DLH calysto_assert()? */
32
 
#define NTP_INVARIANT(x)        calysto_assume(x)
33
 
#define NTP_ENSURE(x)           calysto_assert(x)
 
34
#define ALWAYS_REQUIRE(x)       calysto_assert(x)
 
35
#define ALWAYS_INSIST(x)        calysto_assume(x) /* DLH calysto_assert()? */
 
36
#define ALWAYS_INVARIANT(x)     calysto_assume(x)
 
37
#define ALWAYS_ENSURE(x)        calysto_assert(x)
34
38
 
35
 
# elif defined(__COVERITY__)
 
39
/* # elif defined(__COVERITY__) */
 
40
/*
 
41
 * DH: try letting coverity scan our actual assertion macros, now that
 
42
 * isc_assertioncallback_t is marked __attribute__ __noreturn__.
 
43
 */
36
44
 
37
45
/*
38
46
 * Coverity has special knowledge that assert(x) terminates the process
42
50
 * that seems to be a reasonable trade-off.
43
51
 */
44
52
 
45
 
#define NTP_REQUIRE(x)          assert(x)
46
 
#define NTP_INSIST(x)           assert(x)
47
 
#define NTP_INVARIANT(x)        assert(x)
48
 
#define NTP_ENSURE(x)           assert(x)
 
53
/*
 
54
#define ALWAYS_REQUIRE(x)       assert(x)
 
55
#define ALWAYS_INSIST(x)        assert(x)
 
56
#define ALWAYS_INVARIANT(x)     assert(x)
 
57
#define ALWAYS_ENSURE(x)        assert(x)
 
58
*/
49
59
 
50
60
# else  /* neither Coverity nor Calysto */
51
61
 
52
62
#include "isc/assertions.h"
53
63
 
54
 
#define NTP_REQUIRE(x)          ISC_REQUIRE(x)
55
 
#define NTP_INSIST(x)           ISC_INSIST(x)
56
 
#define NTP_INVARIANT(x)        ISC_INVARIANT(x)
57
 
#define NTP_ENSURE(x)           ISC_ENSURE(x)
 
64
#define ALWAYS_REQUIRE(x)       ISC_REQUIRE(x)
 
65
#define ALWAYS_INSIST(x)        ISC_INSIST(x)
 
66
#define ALWAYS_INVARIANT(x)     ISC_INVARIANT(x)
 
67
#define ALWAYS_ENSURE(x)        ISC_ENSURE(x)
58
68
 
59
69
# endif /* neither Coverity nor Calysto */
 
70
 
 
71
#define REQUIRE(x)              ALWAYS_REQUIRE(x)
 
72
#define INSIST(x)               ALWAYS_INSIST(x)
 
73
#define INVARIANT(x)            ALWAYS_INVARIANT(x)
 
74
#define ENSURE(x)               ALWAYS_ENSURE(x)
 
75
 
 
76
/*
 
77
 * We initially used NTP_REQUIRE() instead of REQUIRE() etc, but that
 
78
 * is unneccesarily verbose, as libisc use of REQUIRE() etc shows.
 
79
 */
 
80
#define NTP_REQUIRE(x)          REQUIRE(x)
 
81
#define NTP_INSIST(x)           INSIST(x)
 
82
#define NTP_INVARIANT(x)        INVARIANT(x)
 
83
#define NTP_ENSURE(x)           ENSURE(x)
 
84
 
 
85
# ifdef DEBUG
 
86
#define DEBUG_REQUIRE(x)        REQUIRE(x)
 
87
#define DEBUG_INSIST(x)         INSIST(x)
 
88
#define DEBUG_INVARIANT(x)      INVARIANT(x)
 
89
#define DEBUG_ENSURE(x)         ENSURE(x)
 
90
# else
 
91
#define DEBUG_REQUIRE(x)        (void)(x)
 
92
#define DEBUG_INSIST(x)         (void)(x)
 
93
#define DEBUG_INVARIANT(x)      (void)(x)
 
94
#define DEBUG_ENSURE(x)         (void)(x)
 
95
# endif
 
96
 
60
97
#endif  /* NTP_ASSERT_H */