Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP4:Update
wicked.33329
0003-move-all-attribute-definitions-to-compiler...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0003-move-all-attribute-definitions-to-compiler-h.patch of Package wicked.33329
From 71c88af525fe35e32af665dfa776104aa2a48f67 Mon Sep 17 00:00:00 2001 From: Clemens Famulla-Conrad <cfamullaconrad@suse.de> Date: Tue, 19 Mar 2024 10:15:12 +0100 Subject: [PATCH 1/3] Move all __attribute__ definitions to compiler.h --- client/ifreload.c | 15 +++++++------- include/Makefile.am | 1 + include/wicked/compiler.h | 42 +++++++++++++++++++++++++++++++++++++++ include/wicked/logging.h | 24 +++++++++------------- src/duid.c | 9 +-------- src/duid.h | 15 +++++--------- src/fsm.c | 3 ++- testing/wunit.h | 5 +++-- 8 files changed, 71 insertions(+), 43 deletions(-) create mode 100644 include/wicked/compiler.h diff --git a/client/ifreload.c b/client/ifreload.c index 8786cb3b..d8525457 100644 --- a/client/ifreload.c +++ b/client/ifreload.c @@ -38,6 +38,7 @@ #include <wicked/netinfo.h> #include <wicked/logging.h> #include <wicked/fsm.h> +#include <wicked/compiler.h> #include "wicked-client.h" #include "appconfig.h" @@ -59,7 +60,7 @@ ifreload_mark_add(ni_ifworker_array_t *marked, ni_ifworker_t *w) static inline void ifreload_mark_down_lower_deps(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifworker_t *lower, - void (*logit)(const char *, ...) __fmtattr) + void (*logit)(const char *, ...) ni__printf(1, 2)) { ni_ifworker_t *w; unsigned int i; @@ -94,7 +95,7 @@ ifreload_mark_down_lower_deps(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, static ni_bool_t ifreload_mark_down(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifworker_t *w, - void (*logit)(const char *, ...) __fmtattr, + void (*logit)(const char *, ...) ni__printf(1, 2), unsigned int depth) { /* ifdown is disabled when persistent mode is on (todo: add --force?) */ @@ -176,7 +177,7 @@ ifreload_mark_down(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifworker static void ifreload_mark_up_slave_deps(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifworker_t *master, - void (*logit)(const char *, ...) __fmtattr) + void (*logit)(const char *, ...) ni__printf(1, 2)) { ni_ifworker_t *w; unsigned int i; @@ -207,7 +208,7 @@ ifreload_mark_up_slave_deps(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni static void ifreload_mark_up_master(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifworker_t *w, - void (*logit)(const char *, ...) __fmtattr) + void (*logit)(const char *, ...) ni__printf(1, 2)) { if (!ni_ifcheck_worker_config_exists(w)) { logit("skipping %s set-up: no configuration available", w->name); @@ -228,7 +229,7 @@ ifreload_mark_up_master(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifw static void ifreload_mark_up_lower_deps(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifworker_t *lower, - void (*logit)(const char *, ...) __fmtattr) + void (*logit)(const char *, ...) ni__printf(1, 2)) { ni_ifworker_t *w; unsigned int i; @@ -268,7 +269,7 @@ ifreload_mark_up_lower_deps(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni static ni_bool_t ifreload_mark_up(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifworker_t *w, - void (*logit)(const char *, ...) __fmtattr) + void (*logit)(const char *, ...) ni__printf(1, 2)) { if (!ni_ifcheck_worker_config_exists(w)) { logit("skipping %s set-up: no configuration available", w->name); @@ -299,7 +300,7 @@ ifreload_mark_up(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifworker_t static void ifreload_mark_workers(const ni_fsm_t *fsm, ni_ifworker_array_t *down_marked, ni_ifworker_array_t *up_marked, const char *ifname) { - void (*logit)(const char *, ...) __fmtattr = ifname ? ni_note : ni_info; + void (*logit)(const char *, ...) ni__printf(1, 2) = ifname ? ni_note : ni_info; ni_ifworker_t *w; unsigned int i; diff --git a/include/Makefile.am b/include/Makefile.am index b913cafa..fed931d1 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -10,6 +10,7 @@ wicked_include_HEADERS = \ wicked/bridge.h \ wicked/client.h \ wicked/constants.h \ + wicked/compiler.h \ wicked/dbus.h \ wicked/dbus-errors.h \ wicked/dbus-service.h \ diff --git a/include/wicked/compiler.h b/include/wicked/compiler.h new file mode 100644 index 00000000..f5edf9a2 --- /dev/null +++ b/include/wicked/compiler.h @@ -0,0 +1,42 @@ +/* + * Compiler specific definitions + * + * Copyright (C) 2024 SUSE LLC + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef NI_WICKED_COMPILER_H +#define NI_WICKED_COMPILER_H + +#ifdef __GNUC__ + +# define ni__printf(a, b) __attribute__ ((format (printf, a, b))) +# define ni__noreturn __attribute__ ((noreturn)) +# define ni__packed __attribute__ ((__packed__)) +# define ni__unused __attribute__ ((unused)) +# define ni__constructor __attribute__ ((constructor)) + +#else /* __GNUC__ */ + +# define ni__printf(a, b) /* */ +# define ni__noreturn /* */ +# define ni__packed /* */ +# define ni__unused /* */ +# define ni__constructor /* */ + +#endif + +#endif /* NI_WICKED_COMPILER_H */ diff --git a/include/wicked/logging.h b/include/wicked/logging.h index 7d2fbd89..db8874a5 100644 --- a/include/wicked/logging.h +++ b/include/wicked/logging.h @@ -8,22 +8,16 @@ #define __WICKED_LOGGING_H__ #include <wicked/types.h> +#include <wicked/compiler.h> -#ifdef __GNUC__ -# define __fmtattr __attribute__ ((format (printf, 1, 2))) -# define __noreturn __attribute__ ((noreturn)) -#else -# define __fmtattr /* */ -# define __noreturn /* */ -#endif - -extern void ni_info(const char *, ...) __fmtattr; -extern void ni_note(const char *, ...) __fmtattr; -extern void ni_warn(const char *, ...) __fmtattr; -extern void ni_error(const char *, ...) __fmtattr; -extern void ni_error_extra(const char *, ...) __fmtattr; -extern void ni_trace(const char *, ...) __fmtattr; -extern void ni_fatal(const char *, ...) __fmtattr __noreturn; + +extern void ni_info(const char *, ...) ni__printf(1, 2); +extern void ni_note(const char *, ...) ni__printf(1, 2); +extern void ni_warn(const char *, ...) ni__printf(1, 2); +extern void ni_error(const char *, ...) ni__printf(1, 2); +extern void ni_error_extra(const char *, ...) ni__printf(1, 2); +extern void ni_trace(const char *, ...) ni__printf(1, 2); +extern void ni_fatal(const char *, ...) ni__printf(1, 2) ni__noreturn; extern int ni_enable_debug(const char *); extern int ni_debug_set_default(const char *); diff --git a/src/duid.c b/src/duid.c index 188b9e2d..fcc8321c 100644 --- a/src/duid.c +++ b/src/duid.c @@ -71,11 +71,6 @@ struct ni_duid_map { struct flock flock; }; -/* - * compiler (gcc) specific ... - */ -#define NI_PACKED __attribute__((__packed__)) - /* * DUID typed packed data union */ @@ -84,9 +79,7 @@ typedef union ni_duid_data { ni_duid_llt_t llt; ni_duid_ll_t ll; ni_duid_en_t en; -} NI_PACKED ni_duid_data_t; - -#undef NI_PACKED +} ni__packed ni_duid_data_t; /* diff --git a/src/duid.h b/src/duid.h index 756d7cef..c7eec24c 100644 --- a/src/duid.h +++ b/src/duid.h @@ -27,6 +27,7 @@ #include <wicked/types.h> #include <wicked/util.h> +#include <wicked/compiler.h> /* @@ -61,11 +62,6 @@ #define NI_DUID_TYPE_LL 3 #define NI_DUID_TYPE_UUID 4 -/* - * We use gcc compiler specific attributes for - * these direct access structs to duid members. - */ -#define NI_PACKED __attribute__((__packed__)) /* * DUID type 1, Link-layer address plus time @@ -77,7 +73,7 @@ typedef struct ni_duid_llt { uint16_t hwtype; /* link layer address type */ uint32_t v6time; /* second since 2000 % 2^32 */ unsigned char hwaddr[]; /* link layer address */ -} NI_PACKED ni_duid_llt_t; +} ni__packed ni_duid_llt_t; /* * DUID type 2, Vendor-assigned unique ID based on Enterprise Number @@ -89,7 +85,7 @@ typedef struct ni_duid_en { uint16_t type; /* type 2 */ uint32_t enterprise; /* assigned enterprise-number */ unsigned char identifier[]; /* machine unique identifier */ -} NI_PACKED ni_duid_en_t; +} ni__packed ni_duid_en_t; /* * DUID type 3, Link-layer address @@ -100,7 +96,7 @@ typedef struct ni_duid_ll { uint16_t type; /* type 3 */ uint16_t hwtype; /* RFC 826 hardware type code */ unsigned char hwaddr[]; /* link layer address */ -} NI_PACKED ni_duid_ll_t; +} ni__packed ni_duid_ll_t; /* * DUID type 4, UUID-Based DHCPv6 Unique Identifier @@ -111,9 +107,8 @@ typedef struct ni_duid_ll { typedef struct ni_duid_uuid { uint16_t type; /* type 4 */ ni_uuid_t uuid; /* RFC4122 UUID as bytes */ -} NI_PACKED ni_duid_uuid_t; +} ni__packed ni_duid_uuid_t; -#undef NI_PACKED typedef struct ni_duid_map ni_duid_map_t; diff --git a/src/fsm.c b/src/fsm.c index 603e8b44..caadd9b9 100644 --- a/src/fsm.c +++ b/src/fsm.c @@ -26,6 +26,7 @@ #include <wicked/client.h> #include <wicked/bridge.h> #include <wicked/ovs.h> +#include <wicked/compiler.h> #include <xml-schema.h> #include "dbus-objects/model.h" @@ -2910,7 +2911,7 @@ ni_ifworker_type_from_object_path(const char *path, const char **suffix) unsigned int ni_fsm_get_matching_workers(ni_fsm_t *fsm, ni_ifmatcher_t *match, ni_ifworker_array_t *result) { - void (*logit)(const char *, ...) __fmtattr; + void (*logit)(const char *, ...) ni__printf(1, 2); unsigned int i; if (ni_string_eq(match->name, "all")) { diff --git a/testing/wunit.h b/testing/wunit.h index af79826f..84f14223 100644 --- a/testing/wunit.h +++ b/testing/wunit.h @@ -43,6 +43,7 @@ #include <string.h> #include <wicked/logging.h> #include <wicked/util.h> +#include <wicked/compiler.h> typedef struct wunit_s wunit_t; typedef void (*wunit_test_fn)(); @@ -60,7 +61,7 @@ struct wunit_s { *current; }; -__attribute__((unused)) static wunit_t wunit_ctx = { +ni__unused static wunit_t wunit_ctx = { .testcases_idx = 0, .fail = 0, .ok = 0, @@ -110,7 +111,7 @@ __attribute__((unused)) static wunit_t wunit_ctx = { #define TESTCASE(ts_name) \ static void testcase_##ts_name(void); \ - static void wunit_register_##ts_name(void) __attribute__((constructor)); \ + static void wunit_register_##ts_name(void) ni__constructor; \ static void wunit_register_##ts_name(void) \ { \ unsigned int i = wunit_ctx.testcases_idx; \ -- 2.35.3 From c273e4f26650059b69c097c671b7bfb8c1018068 Mon Sep 17 00:00:00 2001 From: Clemens Famulla-Conrad <cfamullaconrad@suse.de> Date: Tue, 19 Mar 2024 10:16:03 +0100 Subject: [PATCH 2/3] wunit.h: add header guard macros --- testing/wunit.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/testing/wunit.h b/testing/wunit.h index 84f14223..6fb31d60 100644 --- a/testing/wunit.h +++ b/testing/wunit.h @@ -38,6 +38,9 @@ * make check */ +#ifndef NI_TESTING_WUNIT_H +#define NI_TESTING_WUNIT_H + #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -151,3 +154,5 @@ ni__unused static wunit_t wunit_ctx = { \ return wunit_ctx.fail > 0 ? 1 : 0; \ } + +#endif /* NI_TESTING_WUNIT_H */ -- 2.35.3 From 4847702c1872661e80e5802cbf8405c033d310ec Mon Sep 17 00:00:00 2001 From: Clemens Famulla-Conrad <cfamullaconrad@suse.de> Date: Tue, 19 Mar 2024 10:16:03 +0100 Subject: [PATCH 3/3] logging.h: align header guard macro --- include/wicked/logging.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/wicked/logging.h b/include/wicked/logging.h index db8874a5..4938450e 100644 --- a/include/wicked/logging.h +++ b/include/wicked/logging.h @@ -4,8 +4,8 @@ * Copyright (C) 2010-2012 Olaf Kirch <okir@suse.de> */ -#ifndef __WICKED_LOGGING_H__ -#define __WICKED_LOGGING_H__ +#ifndef NI_WICKED_LOGGING_H +#define NI_WICKED_LOGGING_H #include <wicked/types.h> #include <wicked/compiler.h> @@ -143,4 +143,4 @@ extern unsigned int ni_log_level; __warned = 1; \ } while (0) -#endif /* __WICKED_LOGGING_H__ */ +#endif /* NI_WICKED_LOGGING_H */ -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor