Merge pull request #11031 from poettering/gcc-attr-cleanup

various gcc attribute clean-ups
This commit is contained in:
Lennart Poettering
2018-12-03 21:59:00 +01:00
committed by GitHub
18 changed files with 120 additions and 52 deletions
+5 -7
View File
@@ -54,8 +54,8 @@ BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_standard_errors[] = {
};
/* GCC maps this magically to the beginning and end of the BUS_ERROR_MAP section */
extern const sd_bus_error_map __start_BUS_ERROR_MAP[];
extern const sd_bus_error_map __stop_BUS_ERROR_MAP[];
extern const sd_bus_error_map __start_SYSTEMD_BUS_ERROR_MAP[];
extern const sd_bus_error_map __stop_SYSTEMD_BUS_ERROR_MAP[];
/* Additional maps registered with sd_bus_error_add_map() are in this
* NULL terminated array */
@@ -89,9 +89,8 @@ static int bus_error_name_to_errno(const char *name) {
return m->code;
}
m = __start_BUS_ERROR_MAP;
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
while (m < __stop_BUS_ERROR_MAP) {
m = ALIGN_TO_PTR(__start_SYSTEMD_BUS_ERROR_MAP, sizeof(void*));
while (m < __stop_SYSTEMD_BUS_ERROR_MAP) {
/* For magic ELF error maps, the end marker might
* appear in the middle of things, since multiple maps
* might appear in the same section. Hence, let's skip
@@ -99,7 +98,7 @@ static int bus_error_name_to_errno(const char *name) {
* boundary, which is the selected alignment for the
* arrays. */
if (m->code == BUS_ERROR_MAP_END_MARKER) {
m = ALIGN8_PTR(m+1);
m = ALIGN_TO_PTR(m + 1, sizeof(void*));
continue;
}
@@ -108,7 +107,6 @@ static int bus_error_name_to_errno(const char *name) {
m++;
}
#endif
return EIO;
}
+5 -4
View File
@@ -31,13 +31,14 @@ int bus_error_set_errnofv(sd_bus_error *e, int error, const char *format, va_lis
*/
#define BUS_ERROR_MAP_ELF_REGISTER \
__attribute__ ((__section__("BUS_ERROR_MAP"))) \
__attribute__ ((__used__)) \
__attribute__ ((__aligned__(8)))
_section_("SYSTEMD_BUS_ERROR_MAP") \
_used_ \
_alignptr_ \
_variable_no_sanitize_address_
#define BUS_ERROR_MAP_ELF_USE(errors) \
extern const sd_bus_error_map errors[]; \
__attribute__ ((__used__)) \
_used_ \
static const sd_bus_error_map * const CONCATENATE(errors ## _copy_, __COUNTER__) = errors;
/* We use something exotic as end marker, to ensure people build the
+5 -5
View File
@@ -113,18 +113,18 @@ static void test_error(void) {
assert_se(!sd_bus_error_is_set(&error));
}
extern const sd_bus_error_map __start_BUS_ERROR_MAP[];
extern const sd_bus_error_map __stop_BUS_ERROR_MAP[];
extern const sd_bus_error_map __start_SYSTEMD_BUS_ERROR_MAP[];
extern const sd_bus_error_map __stop_SYSTEMD_BUS_ERROR_MAP[];
static void dump_mapping_table(void) {
const sd_bus_error_map *m;
printf("----- errno mappings ------\n");
m = __start_BUS_ERROR_MAP;
while (m < __stop_BUS_ERROR_MAP) {
m = ALIGN_TO_PTR(__start_SYSTEMD_BUS_ERROR_MAP, sizeof(void*));
while (m < __stop_SYSTEMD_BUS_ERROR_MAP) {
if (m->code == BUS_ERROR_MAP_END_MARKER) {
m = ALIGN8_PTR(m+1);
m = ALIGN_TO_PTR(m + 1, sizeof(void*));
continue;
}
+1 -1
View File
@@ -202,7 +202,7 @@ int main(int argc, char *argv[]) {
log_info("message size = %zu, contents =\n%s", sz, h);
#if HAVE_GLIB
#ifndef __SANITIZE_ADDRESS__
#if !HAS_FEATURE_ADDRESS_SANITIZER
{
GDBusMessage *g;
char *p;