Skip to content

Commit

Permalink
Add __attribute__((sentinel)) to all _vanew function declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
winterz committed May 6, 2024
1 parent 9f712bf commit e16b366
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/mkderivedproperties.pl
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ sub insert_code
LIBICAL_ICAL_EXPORT $type icalproperty_get_${lc}(const icalproperty *prop);";

if ($include_vanew) {
print "\nLIBICAL_ICAL_EXPORT icalproperty *icalproperty_vanew_${lc}($type v, ...);\n";
print "\nLIBICAL_ICAL_EXPORT LIBICAL_SENTINEL icalproperty *icalproperty_vanew_${lc}($type v, ...);\n";
}

}
Expand Down
1 change: 1 addition & 0 deletions src/libical/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ install(FILES
icaltypes.h
icalvalue.h
libical_deprecated.h
libical_sentinel.h
libical_ical_export.h
pvl.h
sspm.h
Expand Down
3 changes: 2 additions & 1 deletion src/libical/icalcomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define ICALCOMPONENT_H

#include "libical_deprecated.h"
#include "libical_sentinel.h"
#include "libical_ical_export.h"
#include "icalenums.h" /* Defines icalcomponent_kind */
#include "icalproperty.h"
Expand Down Expand Up @@ -51,7 +52,7 @@ LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_from_string(const char *str
*
* Make sure to pass NULL (not 0) as the final argument!
*/
LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_vanew(icalcomponent_kind kind, ...);
LIBICAL_ICAL_EXPORT LIBICAL_SENTINEL icalcomponent *icalcomponent_vanew(icalcomponent_kind kind, ...);

/** @brief Constructor
*/
Expand Down
1 change: 1 addition & 0 deletions src/libical/icalderivedproperty.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifndef ICALDERIVEDPROPERTY_H
#define ICALDERIVEDPROPERTY_H

#include "libical_sentinel.h"
#include "icalparameter.h"
#include "icalderivedvalue.h"
#include "icalrecur.h"
Expand Down
23 changes: 23 additions & 0 deletions src/libical/libical_sentinel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
SPDX-FileCopyrightText: Allen Winter <[email protected]>
SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
*/

#ifndef LIBICAL_SENTINEL_H
#define LIBICAL_SENTINEL_H

/* sentinel attribute macro */
#if defined(NO_SENTINEL_WARNINGS)
#define LIBICAL_SENTINEL
#else
#if !defined(LIBICAL_SENTINEL)
#if defined(__GNUC__) || defined(__clang__)
#define LIBICAL_SENTINEL __attribute__((sentinel))
#else
/* sentinel attributes are unknown to MSVC */
#define LIBICAL_SENTINEL
#endif
#endif
#endif

#endif

0 comments on commit e16b366

Please sign in to comment.