return -1;
}
+ errno = 0;
*value = strtol(entry->value, &end, 0);
- if (*end != '\0') {
+ if (errno != 0 || end == entry->value || *end != '\0') {
*value = default_value;
errno = EINVAL;
return -1;
return -1;
}
+ errno = 0;
*value = strtoul(entry->value, &end, 0);
- if (*end != '\0') {
+ if (errno != 0 || end == entry->value || *end != '\0') {
*value = default_value;
errno = EINVAL;
return -1;
"[bar]\n"
"# more comments\n"
"number=5252\n"
+ "zero=0\n"
"flag=false\n"
"\n"
"[stuff]\n"
ZUC_ASSERT_EQ(0, r);
ZUC_ASSERT_EQ(5252, n);
+ ZUC_ASSERT_EQ(0, errno);
}
ZUC_TEST_F(config_test_t1, test007, data)
section = weston_config_get_section(config, "bar", NULL, NULL);
r = weston_config_section_get_uint(section, "number", &u, 600);
+
ZUC_ASSERT_EQ(0, r);
ZUC_ASSERT_EQ(5252, u);
+ ZUC_ASSERT_EQ(0, errno);
}
ZUC_TEST_F(config_test_t1, test009, data)
ZUC_ASSERT_EQ(5, i);
}
+ZUC_TEST_F(config_test_t1, test018, data)
+{
+ int r;
+ int32_t n;
+ struct weston_config_section *section;
+ struct weston_config *config = data;
+
+ section = weston_config_get_section(config, "bar", NULL, NULL);
+ r = weston_config_section_get_int(section, "zero", &n, 600);
+
+ ZUC_ASSERT_EQ(0, r);
+ ZUC_ASSERT_EQ(0, n);
+ ZUC_ASSERT_EQ(0, errno);
+}
+
+ZUC_TEST_F(config_test_t1, test019, data)
+{
+ int r;
+ uint32_t n;
+ struct weston_config_section *section;
+ struct weston_config *config = data;
+
+ section = weston_config_get_section(config, "bar", NULL, NULL);
+ r = weston_config_section_get_uint(section, "zero", &n, 600);
+
+ ZUC_ASSERT_EQ(0, r);
+ ZUC_ASSERT_EQ(0, n);
+ ZUC_ASSERT_EQ(0, errno);
+}
+
ZUC_TEST_F(config_test_t2, doesnt_parse, data)
{
struct weston_config *config = data;