aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-03-08 18:52:33 +0100
committerMattias Andrée <maandree@kth.se>2021-03-08 18:52:33 +0100
commitb800ba9e60dfae5af122410b36a4a1b51b83b642 (patch)
tree495b54b344e45510401b56d3eb97b1360fc9fd34
parentm + style fix + check memory allocation overflows (diff)
downloadlibgamma-b800ba9e60dfae5af122410b36a4a1b51b83b642.tar.gz
libgamma-b800ba9e60dfae5af122410b36a4a1b51b83b642.tar.bz2
libgamma-b800ba9e60dfae5af122410b36a4a1b51b83b642.tar.xz
unmark libgamma_value_of_subpixel_order as pure, unmark libgamma_value_of_connector_type as pure, fix whitespace, use goto in libgamma_value_of_{subpixel_order,connector_type} from name case to const case
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libgamma.h4
-rw-r--r--libgamma_value_of_connector_type.c7
-rw-r--r--libgamma_value_of_subpixel_order.c7
-rw-r--r--test.c12
4 files changed, 14 insertions, 16 deletions
diff --git a/libgamma.h b/libgamma.h
index b22f0d8..ab66afc 100644
--- a/libgamma.h
+++ b/libgamma.h
@@ -1979,7 +1979,7 @@ const char *libgamma_const_of_connector_type(enum libgamma_connector_type);
* "LIBGAMMA_CONNECTOR_TYPE_VGA";
* @return Zero on success, `LIBGAMMA_CONNECTOR_TYPE_NOT_RECOGNISED` of not defined
*/
-LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__, __access__(__read_only__, 1), __access__(__write_only__, 2), __pure__)))
+LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__, __access__(__read_only__, 1), __access__(__write_only__, 2))))
int libgamma_value_of_connector_type(const char *, enum libgamma_connector_type *);
@@ -2020,7 +2020,7 @@ const char *libgamma_const_of_subpixel_order(enum libgamma_subpixel_order);
* "Horizontal RGB" and "LIBGAMMA_SUBPIXEL_ORDER_HORIZONTAL_RGB";
* @return Zero on success, `LIBGAMMA_SUBPIXEL_ORDER_NOT_RECOGNISED` of not defined
*/
-LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__, __access__(__read_only__, 1), __access__(__write_only__, 2), __pure__)))
+LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__, __access__(__read_only__, 1), __access__(__write_only__, 2))))
int libgamma_value_of_subpixel_order(const char *, enum libgamma_subpixel_order *);
diff --git a/libgamma_value_of_connector_type.c b/libgamma_value_of_connector_type.c
index 395aed0..f42e1e5 100644
--- a/libgamma_value_of_connector_type.c
+++ b/libgamma_value_of_connector_type.c
@@ -16,15 +16,14 @@ int
libgamma_value_of_connector_type(const char *connector, enum libgamma_connector_type *out)
{
#define X(CONST, NAME, ...)\
- if (!strcmp(connector, NAME)) {\
- *out = CONST;\
- return 0;\
- }
+ if (!strcmp(connector, NAME))\
+ goto case_##CONST;
LIST_CONNECTOR_TYPES(X)
#undef X
#define X(CONST, ...)\
if (!strcmp(connector, #CONST)) {\
+ case_##CONST:\
*out = CONST;\
return 0;\
}
diff --git a/libgamma_value_of_subpixel_order.c b/libgamma_value_of_subpixel_order.c
index ed81435..1a66c9f 100644
--- a/libgamma_value_of_subpixel_order.c
+++ b/libgamma_value_of_subpixel_order.c
@@ -16,15 +16,14 @@ int
libgamma_value_of_subpixel_order(const char *order, enum libgamma_subpixel_order *out)
{
#define X(CONST, NAME, ...)\
- if (!strcmp(order, NAME)) {\
- *out = CONST;\
- return 0;\
- }
+ if (!strcmp(order, NAME))\
+ goto case_##CONST;
LIST_SUBPIXEL_ORDERS(X)
#undef X
#define X(CONST, ...)\
if (!strcmp(order, #CONST)) {\
+ case_##CONST:\
*out = CONST;\
return 0;\
}
diff --git a/test.c b/test.c
index 2fbc897..95b8dac 100644
--- a/test.c
+++ b/test.c
@@ -687,14 +687,14 @@ test_connector_types(void)
exit(1);\
}\
type = (enum libgamma_connector_type)-1;\
- if (libgamma_value_of_connector_type(#CONST, &type) || type != CONST) { \
+ if (libgamma_value_of_connector_type(#CONST, &type) || type != CONST) {\
fprintf(stderr, "libgamma_value_of_connector_type(\"%s\") != %s\n", #CONST, #CONST);\
exit(1);\
}\
type = (enum libgamma_connector_type)-1;\
- if (libgamma_value_of_connector_type(libgamma_name_of_connector_type(CONST), &type) || type != CONST) { \
+ if (libgamma_value_of_connector_type(libgamma_name_of_connector_type(CONST), &type) || type != CONST) {\
fprintf(stderr, "libgamma_value_of_connector_type(libgamma_name_of_connector_type(%s)) != %s\n",\
- #CONST, #CONST);\
+ #CONST, #CONST); \
exit(1);\
}\
type = (enum libgamma_connector_type)-1;\
@@ -795,18 +795,18 @@ test_subpixel_orders(void)
exit(1);\
}\
order = (enum libgamma_subpixel_order)-1;\
- if (libgamma_value_of_subpixel_order(#CONST, &order) || order != CONST) { \
+ if (libgamma_value_of_subpixel_order(#CONST, &order) || order != CONST) {\
fprintf(stderr, "libgamma_value_of_subpixel_order(\"%s\") != %s\n", #CONST, #CONST);\
exit(1);\
}\
order = (enum libgamma_subpixel_order)-1;\
- if (libgamma_value_of_subpixel_order(libgamma_name_of_subpixel_order(CONST), &order) || order != CONST) { \
+ if (libgamma_value_of_subpixel_order(libgamma_name_of_subpixel_order(CONST), &order) || order != CONST) {\
fprintf(stderr, "libgamma_value_of_subpixel_order(libgamma_name_of_subpixel_order(%s)) != %s\n",\
#CONST, #CONST);\
exit(1);\
}\
order = (enum libgamma_subpixel_order)-1;\
- if (libgamma_value_of_subpixel_order(#CONST, &order) || order != CONST) { \
+ if (libgamma_value_of_subpixel_order(#CONST, &order) || order != CONST) {\
fprintf(stderr, "libgamma_value_of_subpixel_order(\"%s\") != %s\n", #CONST, #CONST);\
exit(1);\
}\