config-parser: Make get_bool be bool

Wayland innovated a lot of cool things, but non-binary boolean values is
the great advances of our time.

Make config_parser_get_bool() work on boolean values, and switch all its
users.

Signed-off-by: Daniel Stone <daniels@collabora.com>
dev
Daniel Stone 5 years ago committed by Daniel Stone
parent 0a4f6e7d6d
commit 51d995ad82
  1. 4
      clients/desktop-shell.c
  2. 113
      compositor/main.c
  3. 2
      desktop-shell/shell.c
  4. 3
      include/libweston/config-parser.h
  5. 2
      ivi-shell/ivi-shell.c
  6. 6
      shared/config-parser.c
  7. 28
      tests/config-parser-test.c

@ -77,7 +77,7 @@ struct desktop {
struct widget *grab_widget; struct widget *grab_widget;
struct weston_config *config; struct weston_config *config;
int locking; bool locking;
enum cursor_type grab_cursor; enum cursor_type grab_cursor;
@ -1518,7 +1518,7 @@ int main(int argc, char *argv[])
config_file = weston_config_get_name_from_env(); config_file = weston_config_get_name_from_env();
desktop.config = weston_config_parse(config_file); desktop.config = weston_config_parse(config_file);
s = weston_config_get_section(desktop.config, "shell", NULL, NULL); s = weston_config_get_section(desktop.config, "shell", NULL, NULL);
weston_config_section_get_bool(s, "locking", &desktop.locking, 1); weston_config_section_get_bool(s, "locking", &desktop.locking, true);
parse_panel_position(&desktop, s); parse_panel_position(&desktop, s);
parse_clock_format(&desktop, s); parse_clock_format(&desktop, s);

@ -1042,8 +1042,7 @@ weston_compositor_init_config(struct weston_compositor *ec,
struct xkb_rule_names xkb_names; struct xkb_rule_names xkb_names;
struct weston_config_section *s; struct weston_config_section *s;
int repaint_msec; int repaint_msec;
int vt_switching; bool cal;
int cal;
/* weston.ini [keyboard] */ /* weston.ini [keyboard] */
s = weston_config_get_section(config, "keyboard", NULL, NULL); s = weston_config_get_section(config, "keyboard", NULL, NULL);
@ -1067,8 +1066,7 @@ weston_compositor_init_config(struct weston_compositor *ec,
&ec->kb_repeat_delay, 400); &ec->kb_repeat_delay, 400);
weston_config_section_get_bool(s, "vt-switching", weston_config_section_get_bool(s, "vt-switching",
&vt_switching, true); &ec->vt_switching, true);
ec->vt_switching = vt_switching;
/* weston.ini [core] */ /* weston.ini [core] */
s = weston_config_get_section(config, "core", NULL, NULL); s = weston_config_get_section(config, "core", NULL, NULL);
@ -1240,10 +1238,11 @@ static void
allow_content_protection(struct weston_output *output, allow_content_protection(struct weston_output *output,
struct weston_config_section *section) struct weston_config_section *section)
{ {
int allow_hdcp = 1; bool allow_hdcp = true;
if (section) if (section)
weston_config_section_get_bool(section, "allow_hdcp", &allow_hdcp, 1); weston_config_section_get_bool(section, "allow_hdcp",
&allow_hdcp, true);
weston_output_allow_protection(output, allow_hdcp); weston_output_allow_protection(output, allow_hdcp);
} }
@ -1528,7 +1527,7 @@ static void
configure_input_device_scroll(struct weston_config_section *s, configure_input_device_scroll(struct weston_config_section *s,
struct libinput_device *device) struct libinput_device *device)
{ {
int natural; bool natural;
char *method_string = NULL; char *method_string = NULL;
uint32_t methods; uint32_t methods;
enum libinput_config_scroll_method method; enum libinput_config_scroll_method method;
@ -1537,7 +1536,7 @@ configure_input_device_scroll(struct weston_config_section *s,
if (libinput_device_config_scroll_has_natural_scroll(device) && if (libinput_device_config_scroll_has_natural_scroll(device) &&
weston_config_section_get_bool(s, "natural-scroll", weston_config_section_get_bool(s, "natural-scroll",
&natural, 0) == 0) { &natural, false) == 0) {
weston_log(" natural-scroll=%s\n", weston_log(" natural-scroll=%s\n",
natural ? "true" : "false"); natural ? "true" : "false");
libinput_device_config_scroll_set_natural_scroll_enabled( libinput_device_config_scroll_set_natural_scroll_enabled(
@ -1597,13 +1596,13 @@ configure_input_device(struct weston_compositor *compositor,
{ {
struct weston_config_section *s; struct weston_config_section *s;
struct weston_config *config = wet_get_config(compositor); struct weston_config *config = wet_get_config(compositor);
int has_enable_tap = 0; bool has_enable_tap = false;
int enable_tap; bool enable_tap;
int disable_while_typing; bool disable_while_typing;
int middle_emulation; bool middle_emulation;
int tap_and_drag; bool tap_and_drag;
int tap_and_drag_lock; bool tap_and_drag_lock;
int left_handed; bool left_handed;
unsigned int rotation; unsigned int rotation;
weston_log("libinput: configuring device \"%s\".\n", weston_log("libinput: configuring device \"%s\".\n",
@ -1614,16 +1613,16 @@ configure_input_device(struct weston_compositor *compositor,
if (libinput_device_config_tap_get_finger_count(device) > 0) { if (libinput_device_config_tap_get_finger_count(device) > 0) {
if (weston_config_section_get_bool(s, "enable_tap", if (weston_config_section_get_bool(s, "enable_tap",
&enable_tap, 0) == 0) { &enable_tap, false) == 0) {
weston_log("!!DEPRECATION WARNING!!: In weston.ini, " weston_log("!!DEPRECATION WARNING!!: In weston.ini, "
"enable_tap is deprecated in favour of " "enable_tap is deprecated in favour of "
"enable-tap. Support for it may be removed " "enable-tap. Support for it may be removed "
"at any time!"); "at any time!");
has_enable_tap = 1; has_enable_tap = true;
} }
if (weston_config_section_get_bool(s, "enable-tap", if (weston_config_section_get_bool(s, "enable-tap",
&enable_tap, 0) == 0) &enable_tap, false) == 0)
has_enable_tap = 1; has_enable_tap = true;
if (has_enable_tap) { if (has_enable_tap) {
weston_log(" enable-tap=%s.\n", weston_log(" enable-tap=%s.\n",
enable_tap ? "true" : "false"); enable_tap ? "true" : "false");
@ -1631,14 +1630,14 @@ configure_input_device(struct weston_compositor *compositor,
enable_tap); enable_tap);
} }
if (weston_config_section_get_bool(s, "tap-and-drag", if (weston_config_section_get_bool(s, "tap-and-drag",
&tap_and_drag, 0) == 0) { &tap_and_drag, false) == 0) {
weston_log(" tap-and-drag=%s.\n", weston_log(" tap-and-drag=%s.\n",
tap_and_drag ? "true" : "false"); tap_and_drag ? "true" : "false");
libinput_device_config_tap_set_drag_enabled(device, libinput_device_config_tap_set_drag_enabled(device,
tap_and_drag); tap_and_drag);
} }
if (weston_config_section_get_bool(s, "tap-and-drag-lock", if (weston_config_section_get_bool(s, "tap-and-drag-lock",
&tap_and_drag_lock, 0) == 0) { &tap_and_drag_lock, false) == 0) {
weston_log(" tap-and-drag-lock=%s.\n", weston_log(" tap-and-drag-lock=%s.\n",
tap_and_drag_lock ? "true" : "false"); tap_and_drag_lock ? "true" : "false");
libinput_device_config_tap_set_drag_lock_enabled( libinput_device_config_tap_set_drag_lock_enabled(
@ -1648,7 +1647,7 @@ configure_input_device(struct weston_compositor *compositor,
if (libinput_device_config_dwt_is_available(device) && if (libinput_device_config_dwt_is_available(device) &&
weston_config_section_get_bool(s, "disable-while-typing", weston_config_section_get_bool(s, "disable-while-typing",
&disable_while_typing, 0) == 0) { &disable_while_typing, false) == 0) {
weston_log(" disable-while-typing=%s.\n", weston_log(" disable-while-typing=%s.\n",
disable_while_typing ? "true" : "false"); disable_while_typing ? "true" : "false");
libinput_device_config_dwt_set_enabled(device, libinput_device_config_dwt_set_enabled(device,
@ -1657,7 +1656,7 @@ configure_input_device(struct weston_compositor *compositor,
if (libinput_device_config_middle_emulation_is_available(device) && if (libinput_device_config_middle_emulation_is_available(device) &&
weston_config_section_get_bool(s, "middle-button-emulation", weston_config_section_get_bool(s, "middle-button-emulation",
&middle_emulation, 0) == 0) { &middle_emulation, false) == 0) {
weston_log(" middle-button-emulation=%s\n", weston_log(" middle-button-emulation=%s\n",
middle_emulation ? "true" : "false"); middle_emulation ? "true" : "false");
libinput_device_config_middle_emulation_set_enabled( libinput_device_config_middle_emulation_set_enabled(
@ -1666,7 +1665,7 @@ configure_input_device(struct weston_compositor *compositor,
if (libinput_device_config_left_handed_is_available(device) && if (libinput_device_config_left_handed_is_available(device) &&
weston_config_section_get_bool(s, "left-handed", weston_config_section_get_bool(s, "left-handed",
&left_handed, 0) == 0) { &left_handed, false) == 0) {
weston_log(" left-handed=%s\n", weston_log(" left-handed=%s\n",
left_handed ? "true" : "false"); left_handed ? "true" : "false");
libinput_device_config_left_handed_set(device, left_handed); libinput_device_config_left_handed_set(device, left_handed);
@ -1674,7 +1673,7 @@ configure_input_device(struct weston_compositor *compositor,
if (libinput_device_config_rotation_is_available(device) && if (libinput_device_config_rotation_is_available(device) &&
weston_config_section_get_uint(s, "rotation", weston_config_section_get_uint(s, "rotation",
&rotation, 0) == 0) { &rotation, false) == 0) {
weston_log(" rotation=%u\n", rotation); weston_log(" rotation=%u\n", rotation);
libinput_device_config_rotation_set_angle(device, rotation); libinput_device_config_rotation_set_angle(device, rotation);
} }
@ -1973,14 +1972,14 @@ drm_head_should_force_enable(struct wet_compositor *wet,
{ {
const char *name = weston_head_get_name(head); const char *name = weston_head_get_name(head);
struct weston_config_section *section; struct weston_config_section *section;
int force = 0; bool force;
section = drm_config_find_controlling_output_section(wet->config, name); section = drm_config_find_controlling_output_section(wet->config, name);
if (!section) if (!section)
return false; return false;
weston_config_section_get_bool(section, "force-on", &force, 0); weston_config_section_get_bool(section, "force-on", &force, false);
return !!force; return force;
} }
static void static void
@ -2481,17 +2480,17 @@ load_drm_backend(struct weston_compositor *c,
struct weston_drm_backend_config config = {{ 0, }}; struct weston_drm_backend_config config = {{ 0, }};
struct weston_config_section *section; struct weston_config_section *section;
struct wet_compositor *wet = to_wet_compositor(c); struct wet_compositor *wet = to_wet_compositor(c);
int use_shadow; bool use_shadow;
int ret = 0; int ret = 0;
int use_pixman_config_ = 0; bool use_pixman_config_;
int drm_use_current_mode = 0; int drm_use_current_mode = 0;
int32_t use_pixman_ = 0; int32_t use_pixman_;
wet->drm_use_current_mode = false; wet->drm_use_current_mode = false;
section = weston_config_get_section(wc, "core", NULL, NULL); section = weston_config_get_section(wc, "core", NULL, NULL);
weston_config_section_get_bool(section, "use-pixman", &use_pixman_config_, weston_config_section_get_bool(section, "use-pixman", &use_pixman_config_,
use_pixman_config_); false);
use_pixman_ = use_pixman_config_; use_pixman_ = use_pixman_config_;
const struct weston_option options[] = { const struct weston_option options[] = {
@ -2512,7 +2511,7 @@ load_drm_backend(struct weston_compositor *c,
NULL); NULL);
weston_config_section_get_uint(section, "pageflip-timeout", weston_config_section_get_uint(section, "pageflip-timeout",
&config.pageflip_timeout, 0); &config.pageflip_timeout, 0);
weston_config_section_get_bool(section, "pixman-shadow", &use_shadow, 1); weston_config_section_get_bool(section, "pixman-shadow", &use_shadow, true);
config.use_pixman_shadow = use_shadow; config.use_pixman_shadow = use_shadow;
config.base.struct_version = WESTON_DRM_BACKEND_CONFIG_VERSION; config.base.struct_version = WESTON_DRM_BACKEND_CONFIG_VERSION;
@ -2561,10 +2560,10 @@ load_headless_backend(struct weston_compositor *c,
int no_outputs = 0; int no_outputs = 0;
int ret = 0; int ret = 0;
char *transform = NULL; char *transform = NULL;
int32_t use_pixman_config_ = 0; bool use_pixman_config_;
int use_pixman_ = 0; int use_pixman_;
int32_t use_gl_config_ = 0; bool use_gl_config_;
int use_gl_ = 0; bool use_gl_;
struct wet_output_config *parsed_options = wet_init_parsed_options(c); struct wet_output_config *parsed_options = wet_init_parsed_options(c);
if (!parsed_options) if (!parsed_options)
@ -2572,10 +2571,10 @@ load_headless_backend(struct weston_compositor *c,
section = weston_config_get_section(wc, "core", NULL, NULL); section = weston_config_get_section(wc, "core", NULL, NULL);
weston_config_section_get_bool(section, "use-pixman", &use_pixman_config_, weston_config_section_get_bool(section, "use-pixman", &use_pixman_config_,
use_pixman_config_); false);
use_pixman_ = use_pixman_config_; use_pixman_ = use_pixman_config_;
weston_config_section_get_bool(section, "use-gl", &use_gl_config_, weston_config_section_get_bool(section, "use-gl", &use_gl_config_,
use_gl_config_); false);
use_gl_ = use_gl_config_; use_gl_ = use_gl_config_;
const struct weston_option options[] = { const struct weston_option options[] = {
@ -2786,10 +2785,10 @@ load_x11_backend(struct weston_compositor *c,
int output_count = 0; int output_count = 0;
char const *section_name; char const *section_name;
int i; int i;
int32_t use_pixman_config_ = 0; bool use_pixman_config_;
int fullscreen = 0; int fullscreen = 0;
int no_input = 0; int no_input = 0;
int use_pixman_ = 0; int use_pixman_;
struct wet_output_config *parsed_options = wet_init_parsed_options(c); struct wet_output_config *parsed_options = wet_init_parsed_options(c);
if (!parsed_options) if (!parsed_options)
@ -2797,7 +2796,7 @@ load_x11_backend(struct weston_compositor *c,
section = weston_config_get_section(wc, "core", NULL, NULL); section = weston_config_get_section(wc, "core", NULL, NULL);
weston_config_section_get_bool(section, "use-pixman", &use_pixman_config_, weston_config_section_get_bool(section, "use-pixman", &use_pixman_config_,
use_pixman_config_); false);
use_pixman_ = use_pixman_config_; use_pixman_ = use_pixman_config_;
const struct weston_option options[] = { const struct weston_option options[] = {
@ -2902,10 +2901,10 @@ load_wayland_backend(struct weston_compositor *c,
int count = 1; int count = 1;
int ret = 0; int ret = 0;
int i; int i;
int32_t use_pixman_ = 0; int32_t use_pixman_;
int32_t sprawl_ = 0; int32_t sprawl_ = 0;
int32_t fullscreen_ = 0; int32_t fullscreen_ = 0;
int use_pixman_config_ = 0; bool use_pixman_config_;
struct wet_output_config *parsed_options = wet_init_parsed_options(c); struct wet_output_config *parsed_options = wet_init_parsed_options(c);
if (!parsed_options) if (!parsed_options)
@ -2917,7 +2916,7 @@ load_wayland_backend(struct weston_compositor *c,
section = weston_config_get_section(wc, "core", NULL, NULL); section = weston_config_get_section(wc, "core", NULL, NULL);
weston_config_section_get_bool(section, "use-pixman", &use_pixman_config_, weston_config_section_get_bool(section, "use-pixman", &use_pixman_config_,
use_pixman_config_); false);
use_pixman_ = use_pixman_config_; use_pixman_ = use_pixman_config_;
const struct weston_option wayland_options[] = { const struct weston_option wayland_options[] = {
@ -3121,6 +3120,7 @@ wet_main(int argc, char *argv[])
char *backend = NULL; char *backend = NULL;
char *shell = NULL; char *shell = NULL;
int32_t xwayland = 0; int32_t xwayland = 0;
bool xwayland_config_;
char *modules = NULL; char *modules = NULL;
char *option_modules = NULL; char *option_modules = NULL;
char *log = NULL; char *log = NULL;
@ -3133,7 +3133,7 @@ wet_main(int argc, char *argv[])
int32_t version = 0; int32_t version = 0;
int32_t noconfig = 0; int32_t noconfig = 0;
int32_t debug_protocol = 0; int32_t debug_protocol = 0;
int32_t numlock_on; bool numlock_on;
char *config_file = NULL; char *config_file = NULL;
struct weston_config *config = NULL; struct weston_config *config = NULL;
struct weston_config_section *section; struct weston_config_section *section;
@ -3144,10 +3144,10 @@ wet_main(int argc, char *argv[])
struct weston_log_context *log_ctx = NULL; struct weston_log_context *log_ctx = NULL;
struct weston_log_subscriber *logger = NULL; struct weston_log_subscriber *logger = NULL;
struct weston_log_subscriber *flight_rec = NULL; struct weston_log_subscriber *flight_rec = NULL;
int require_input;
sigset_t mask; sigset_t mask;
int32_t wait_for_debugger = 0; int32_t wait_for_debugger = 0;
bool wait_for_debugger_config_;
struct wl_protocol_logger *protologger = NULL; struct wl_protocol_logger *protologger = NULL;
const struct weston_option core_options[] = { const struct weston_option core_options[] = {
@ -3255,9 +3255,11 @@ wet_main(int argc, char *argv[])
section = weston_config_get_section(config, "core", NULL, NULL); section = weston_config_get_section(config, "core", NULL, NULL);
if (!wait_for_debugger) if (!wait_for_debugger) {
weston_config_section_get_bool(section, "wait-for-debugger", weston_config_section_get_bool(section, "wait-for-debugger",
&wait_for_debugger, 0); &wait_for_debugger_config_, false);
wait_for_debugger = wait_for_debugger_config_;
}
if (wait_for_debugger) { if (wait_for_debugger) {
weston_log("Weston PID is %ld - " weston_log("Weston PID is %ld - "
"waiting for debugger, send SIGCONT to continue...\n", "waiting for debugger, send SIGCONT to continue...\n",
@ -3299,8 +3301,7 @@ wet_main(int argc, char *argv[])
goto out; goto out;
weston_config_section_get_bool(section, "require-input", weston_config_section_get_bool(section, "require-input",
&require_input, true); &wet.compositor->require_input, true);
wet.compositor->require_input = require_input;
if (load_backend(wet.compositor, backend, &argc, argv, config) < 0) { if (load_backend(wet.compositor, backend, &argc, argv, config) < 0) {
weston_log("fatal: failed to create compositor backend\n"); weston_log("fatal: failed to create compositor backend\n");
@ -3360,16 +3361,18 @@ wet_main(int argc, char *argv[])
if (load_modules(wet.compositor, option_modules, &argc, argv, &xwayland) < 0) if (load_modules(wet.compositor, option_modules, &argc, argv, &xwayland) < 0)
goto out; goto out;
if (!xwayland) if (!xwayland) {
weston_config_section_get_bool(section, "xwayland", &xwayland, weston_config_section_get_bool(section, "xwayland",
false); &xwayland_config_, false);
xwayland = xwayland_config_;
}
if (xwayland) { if (xwayland) {
if (wet_load_xwayland(wet.compositor) < 0) if (wet_load_xwayland(wet.compositor) < 0)
goto out; goto out;
} }
section = weston_config_get_section(config, "keyboard", NULL, NULL); section = weston_config_get_section(config, "keyboard", NULL, NULL);
weston_config_section_get_bool(section, "numlock-on", &numlock_on, 0); weston_config_section_get_bool(section, "numlock-on", &numlock_on, false);
if (numlock_on) { if (numlock_on) {
wl_list_for_each(seat, &wet.compositor->seat_list, link) { wl_list_for_each(seat, &wet.compositor->seat_list, link) {
struct weston_keyboard *keyboard = struct weston_keyboard *keyboard =

@ -464,7 +464,7 @@ shell_configuration(struct desktop_shell *shell)
{ {
struct weston_config_section *section; struct weston_config_section *section;
char *s, *client; char *s, *client;
int allow_zap; bool allow_zap;
section = weston_config_get_section(wet_get_config(shell->compositor), section = weston_config_get_section(wet_get_config(shell->compositor),
"shell", NULL, NULL); "shell", NULL, NULL);

@ -30,6 +30,7 @@
extern "C" { extern "C" {
#endif #endif
#include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#define WESTON_CONFIG_FILE_ENV_VAR "WESTON_CONFIG_FILE" #define WESTON_CONFIG_FILE_ENV_VAR "WESTON_CONFIG_FILE"
@ -102,7 +103,7 @@ weston_config_section_get_string(struct weston_config_section *section,
int int
weston_config_section_get_bool(struct weston_config_section *section, weston_config_section_get_bool(struct weston_config_section *section,
const char *key, const char *key,
int *value, int default_value); bool *value, bool default_value);
const char * const char *
weston_config_get_name_from_env(void); weston_config_get_name_from_env(void);

@ -379,7 +379,7 @@ init_ivi_shell(struct weston_compositor *compositor, struct ivi_shell *shell)
{ {
struct weston_config *config = wet_get_config(compositor); struct weston_config *config = wet_get_config(compositor);
struct weston_config_section *section; struct weston_config_section *section;
int developermode; bool developermode;
shell->compositor = compositor; shell->compositor = compositor;

@ -302,7 +302,7 @@ WL_EXPORT
int int
weston_config_section_get_bool(struct weston_config_section *section, weston_config_section_get_bool(struct weston_config_section *section,
const char *key, const char *key,
int *value, int default_value) bool *value, bool default_value)
{ {
struct weston_config_entry *entry; struct weston_config_entry *entry;
@ -314,9 +314,9 @@ weston_config_section_get_bool(struct weston_config_section *section,
} }
if (strcmp(entry->value, "false") == 0) if (strcmp(entry->value, "false") == 0)
*value = 0; *value = false;
else if (strcmp(entry->value, "true") == 0) else if (strcmp(entry->value, "true") == 0)
*value = 1; *value = true;
else { else {
*value = default_value; *value = default_value;
errno = EINVAL; errno = EINVAL;

@ -322,51 +322,55 @@ ZUC_TEST_F(config_test_t1, test009, data)
ZUC_TEST_F(config_test_t1, test010, data) ZUC_TEST_F(config_test_t1, test010, data)
{ {
int r, b; int r;
bool b;
struct weston_config_section *section; struct weston_config_section *section;
struct weston_config *config = data; struct weston_config *config = data;
section = weston_config_get_section(config, "bar", NULL, NULL); section = weston_config_get_section(config, "bar", NULL, NULL);
r = weston_config_section_get_bool(section, "flag", &b, 600); r = weston_config_section_get_bool(section, "flag", &b, true);
ZUC_ASSERT_EQ(0, r); ZUC_ASSERT_EQ(0, r);
ZUC_ASSERT_EQ(0, b); ZUC_ASSERT_EQ(false, b);
} }
ZUC_TEST_F(config_test_t1, test011, data) ZUC_TEST_F(config_test_t1, test011, data)
{ {
int r, b; int r;
bool b;
struct weston_config_section *section; struct weston_config_section *section;
struct weston_config *config = data; struct weston_config *config = data;
section = weston_config_get_section(config, "stuff", NULL, NULL); section = weston_config_get_section(config, "stuff", NULL, NULL);
r = weston_config_section_get_bool(section, "flag", &b, -1); r = weston_config_section_get_bool(section, "flag", &b, false);
ZUC_ASSERT_EQ(0, r); ZUC_ASSERT_EQ(0, r);
ZUC_ASSERT_EQ(1, b); ZUC_ASSERT_EQ(true, b);
} }
ZUC_TEST_F(config_test_t1, test012, data) ZUC_TEST_F(config_test_t1, test012, data)
{ {
int r, b; int r;
bool b;
struct weston_config_section *section; struct weston_config_section *section;
struct weston_config *config = data; struct weston_config *config = data;
section = weston_config_get_section(config, "stuff", NULL, NULL); section = weston_config_get_section(config, "stuff", NULL, NULL);
r = weston_config_section_get_bool(section, "flag", &b, -1); r = weston_config_section_get_bool(section, "flag", &b, false);
ZUC_ASSERT_EQ(0, r); ZUC_ASSERT_EQ(0, r);
ZUC_ASSERT_EQ(1, b); ZUC_ASSERT_EQ(true, b);
} }
ZUC_TEST_F(config_test_t1, test013, data) ZUC_TEST_F(config_test_t1, test013, data)
{ {
int r, b; int r;
bool b;
struct weston_config_section *section; struct weston_config_section *section;
struct weston_config *config = data; struct weston_config *config = data;
section = weston_config_get_section(config, "stuff", NULL, NULL); section = weston_config_get_section(config, "stuff", NULL, NULL);
r = weston_config_section_get_bool(section, "bonk", &b, -1); r = weston_config_section_get_bool(section, "bonk", &b, false);
ZUC_ASSERT_EQ(-1, r); ZUC_ASSERT_EQ(-1, r);
ZUC_ASSERT_EQ(ENOENT, errno); ZUC_ASSERT_EQ(ENOENT, errno);
ZUC_ASSERT_EQ(-1, b); ZUC_ASSERT_EQ(false, b);
} }
ZUC_TEST_F(config_test_t1, test014, data) ZUC_TEST_F(config_test_t1, test014, data)

Loading…
Cancel
Save