public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/libdm libdm-config.c
@ 2011-12-11 15:18 mornfall
0 siblings, 0 replies; 11+ messages in thread
From: mornfall @ 2011-12-11 15:18 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mornfall@sourceware.org 2011-12-11 15:18:32
Modified files:
libdm : libdm-config.c
Log message:
In the dm_config_*get_* functions, make the actual value retrieval optional
(useful for just checking that a given key is of a given type).
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
--- LVM2/libdm/libdm-config.c 2011/10/28 20:07:38 1.15
+++ LVM2/libdm/libdm-config.c 2011/12/11 15:18:32 1.16
@@ -1111,7 +1111,8 @@
if (!n || !n->v || n->v->type != DM_CFG_INT)
return 0;
- *result = n->v->v.i;
+ if (result)
+ *result = n->v->v.i;
return 1;
}
@@ -1125,7 +1126,8 @@
if (!n || !n->v || n->v->type != DM_CFG_INT)
return 0;
- *result = (uint64_t) n->v->v.i;
+ if (result)
+ *result = (uint64_t) n->v->v.i;
return 1;
}
@@ -1139,7 +1141,8 @@
if (!n || !n->v || n->v->type != DM_CFG_STRING)
return 0;
- *result = n->v->v.str;
+ if (result)
+ *result = n->v->v.str;
return 1;
}
@@ -1154,7 +1157,8 @@
if (!n || !n->v)
return 0;
- *result = n->v;
+ if (result)
+ *result = n->v;
return 1;
}
@@ -1167,7 +1171,8 @@
if (!n || n->v)
return 0;
- *result = n;
+ if (result)
+ *result = n;
return 1;
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* LVM2/libdm libdm-config.c
@ 2012-02-28 17:46 agk
0 siblings, 0 replies; 11+ messages in thread
From: agk @ 2012-02-28 17:46 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2012-02-28 17:46:47
Modified files:
libdm : libdm-config.c
Log message:
Fix empty string warning logic in _find_config_str. (1.02.68)
pvcreate gives
WARNING: Ignoring unsupported value for metadata/pvmetadataignore.
It was warning if there is no config file entry instead of only if the node
exists but is empty.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.21&r2=1.22
--- LVM2/libdm/libdm-config.c 2012/01/23 17:47:36 1.21
+++ LVM2/libdm/libdm-config.c 2012/02/28 17:46:47 1.22
@@ -751,14 +751,16 @@
{
const struct dm_config_node *n = find_fn(start, path);
- /* Empty strings are ignored */
- if ((n && n->v && n->v->type == DM_CFG_STRING) &&
- (allow_empty || (*n->v->v.str))) {
- log_very_verbose("Setting %s to %s", path, n->v->v.str);
- return n->v->v.str;
- } else if (n && (!n->v || (n->v->type != DM_CFG_STRING) ||
- (!allow_empty && fail)))
- log_warn("WARNING: Ignoring unsupported value for %s.", path);
+ /* Empty strings are ignored if allow_empty is set */
+ if (n && n->v) {
+ if ((n->v->type == DM_CFG_STRING) &&
+ (allow_empty || (*n->v->v.str))) {
+ log_very_verbose("Setting %s to %s", path, n->v->v.str);
+ return n->v->v.str;
+ }
+ if ((n->v->type != DM_CFG_STRING) || (!allow_empty && fail))
+ log_warn("WARNING: Ignoring unsupported value for %s.", path);
+ }
if (fail)
log_very_verbose("%s not found in config: defaulting to %s",
^ permalink raw reply [flat|nested] 11+ messages in thread
* LVM2/libdm libdm-config.c
@ 2012-01-23 17:47 agk
0 siblings, 0 replies; 11+ messages in thread
From: agk @ 2012-01-23 17:47 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2012-01-23 17:47:36
Modified files:
libdm : libdm-config.c
Log message:
add const
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21
--- LVM2/libdm/libdm-config.c 2012/01/19 15:16:39 1.20
+++ LVM2/libdm/libdm-config.c 2012/01/23 17:47:36 1.21
@@ -852,6 +852,8 @@
case DM_CFG_STRING:
return _str_to_bool(v->v.str, fail);
+ default:
+ ;
}
return fail;
@@ -861,7 +863,7 @@
* node-based lookup
**/
-struct dm_config_node *dm_config_find_node(struct dm_config_node *cn,
+struct dm_config_node *dm_config_find_node(const struct dm_config_node *cn,
const char *path)
{
return (struct dm_config_node *) _find_config_node(cn, path);
^ permalink raw reply [flat|nested] 11+ messages in thread
* LVM2/libdm libdm-config.c
@ 2012-01-19 15:16 zkabelac
0 siblings, 0 replies; 11+ messages in thread
From: zkabelac @ 2012-01-19 15:16 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2012-01-19 15:16:39
Modified files:
libdm : libdm-config.c
Log message:
Update for gcc old-style
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.19&r2=1.20
--- LVM2/libdm/libdm-config.c 2011/12/21 12:47:45 1.19
+++ LVM2/libdm/libdm-config.c 2012/01/19 15:16:39 1.20
@@ -89,7 +89,7 @@
return !(*str || (b != e));
}
-struct dm_config_tree *dm_config_create()
+struct dm_config_tree *dm_config_create(void)
{
struct dm_config_tree *cft;
struct dm_pool *mem = dm_pool_create("config", 10 * 1024);
^ permalink raw reply [flat|nested] 11+ messages in thread
* LVM2/libdm libdm-config.c
@ 2011-09-25 19:45 zkabelac
0 siblings, 0 replies; 11+ messages in thread
From: zkabelac @ 2011-09-25 19:45 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-09-25 19:45:40
Modified files:
libdm : libdm-config.c
Log message:
Remove test for NULL
Since it's internal function and we always check for NULL value
before call - this is safe.
Just for case add nonnull attribute so analyzer might better
catch error.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13
--- LVM2/libdm/libdm-config.c 2011/09/25 19:43:43 1.12
+++ LVM2/libdm/libdm-config.c 2011/09/25 19:45:40 1.13
@@ -1225,14 +1225,12 @@
return 0;
}
+__attribute__((nonnull(1, 2)))
static struct dm_config_value *_clone_config_value(struct dm_pool *mem,
const struct dm_config_value *v)
{
struct dm_config_value *new_cv;
- if (!v)
- return NULL;
-
if (!(new_cv = _create_value(mem))) {
log_error("Failed to clone config value.");
return NULL;
^ permalink raw reply [flat|nested] 11+ messages in thread
* LVM2/libdm libdm-config.c
@ 2011-09-25 19:43 zkabelac
0 siblings, 0 replies; 11+ messages in thread
From: zkabelac @ 2011-09-25 19:43 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-09-25 19:43:43
Modified files:
libdm : libdm-config.c
Log message:
Add missing log_error messages
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12
--- LVM2/libdm/libdm-config.c 2011/09/25 19:42:45 1.11
+++ LVM2/libdm/libdm-config.c 2011/09/25 19:43:43 1.12
@@ -543,8 +543,10 @@
{
/* IDENTIFIER SECTION_B_CHAR VALUE* SECTION_E_CHAR */
struct dm_config_node *root, *n, *l = NULL;
- if (!(root = _create_node(p->mem)))
- return_NULL;
+ if (!(root = _create_node(p->mem))) {
+ log_error("Failed to allocate section node");
+ return NULL;
+ }
if (!(root->key = _dup_tok(p)))
return_NULL;
@@ -598,8 +600,10 @@
* Special case for an empty array.
*/
if (!h) {
- if (!(h = _create_value(p->mem)))
- return_NULL;
+ if (!(h = _create_value(p->mem))) {
+ log_error("Failed to allocate value");
+ return NULL;
+ }
h->type = DM_CFG_EMPTY_ARRAY;
}
@@ -617,8 +621,10 @@
struct dm_config_value *v = _create_value(p->mem);
char *str;
- if (!v)
+ if (!v) {
+ log_error("Failed to allocate type value");
return NULL;
+ }
switch (p->t) {
case TOK_INT:
@@ -1251,8 +1257,10 @@
{
struct dm_config_node *new_cn;
- if (!cn)
+ if (!cn) {
+ log_error("Cannot clone NULL config node.");
return NULL;
+ }
if (!(new_cn = _create_node(mem))) {
log_error("Failed to clone config node.");
^ permalink raw reply [flat|nested] 11+ messages in thread
* LVM2/libdm libdm-config.c
@ 2011-09-25 19:42 zkabelac
0 siblings, 0 replies; 11+ messages in thread
From: zkabelac @ 2011-09-25 19:42 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-09-25 19:42:45
Modified files:
libdm : libdm-config.c
Log message:
Add backtrace when allocation fails for _type
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11
--- LVM2/libdm/libdm-config.c 2011/09/25 19:41:27 1.10
+++ LVM2/libdm/libdm-config.c 2011/09/25 19:42:45 1.11
@@ -605,7 +605,8 @@
}
} else
- h = _type(p);
+ if (!(h = _type(p)))
+ return_NULL;
return h;
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* LVM2/libdm libdm-config.c
@ 2011-09-25 19:41 zkabelac
0 siblings, 0 replies; 11+ messages in thread
From: zkabelac @ 2011-09-25 19:41 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-09-25 19:41:27
Modified files:
libdm : libdm-config.c
Log message:
Replace test for NULL of root->child with test for NULL l
It's 100% equivalent test - since it always happen for the first iteration.
But the check for 'l' is understandable with analyzers - since analyzer
is not smart enough to deduce connection between root->child == NULL.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10
--- LVM2/libdm/libdm-config.c 2011/09/25 19:40:29 1.9
+++ LVM2/libdm/libdm-config.c 2011/09/25 19:41:27 1.10
@@ -557,7 +557,7 @@
if (!(n = _section(p)))
return_NULL;
- if (!root->child)
+ if (!l)
root->child = n;
else
l->sib = n;
^ permalink raw reply [flat|nested] 11+ messages in thread
* LVM2/libdm libdm-config.c
@ 2011-09-25 19:40 zkabelac
0 siblings, 0 replies; 11+ messages in thread
From: zkabelac @ 2011-09-25 19:40 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-09-25 19:40:29
Modified files:
libdm : libdm-config.c
Log message:
Simplier attribute format
No need to repeat whole declaration for static function.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.8&r2=1.9
--- LVM2/libdm/libdm-config.c 2011/09/25 19:39:38 1.8
+++ LVM2/libdm/libdm-config.c 2011/09/25 19:40:29 1.9
@@ -316,8 +316,7 @@
return 1;
}
-static int _line_append(struct output_line *outline, const char *fmt, ...)
- __attribute__ ((format(printf, 2, 3)));
+__attribute__ ((format(printf, 2, 3)))
static int _line_append(struct output_line *outline, const char *fmt, ...)
{
char buf[4096];
^ permalink raw reply [flat|nested] 11+ messages in thread
* LVM2/libdm libdm-config.c
@ 2011-09-25 19:39 zkabelac
0 siblings, 0 replies; 11+ messages in thread
From: zkabelac @ 2011-09-25 19:39 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-09-25 19:39:38
Modified files:
libdm : libdm-config.c
Log message:
Chheck for failing filename strdup
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8
--- LVM2/libdm/libdm-config.c 2011/09/25 19:38:59 1.7
+++ LVM2/libdm/libdm-config.c 2011/09/25 19:39:38 1.8
@@ -127,8 +127,13 @@
c->exists = 0;
c->keep_open = keep_open;
c->custom = NULL;
- if (filename)
- c->filename = dm_pool_strdup(c->mem, filename);
+ if (filename &&
+ !(c->filename = dm_pool_strdup(c->mem, filename))) {
+ log_error("Failed to duplicate filename.");
+ dm_pool_destroy(mem);
+ return 0;
+ }
+
return &c->cft;
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* LVM2/libdm libdm-config.c
@ 2011-09-01 14:02 zkabelac
0 siblings, 0 replies; 11+ messages in thread
From: zkabelac @ 2011-09-01 14:02 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-09-01 14:02:07
Modified files:
libdm : libdm-config.c
Log message:
Use const casting when it's needed
Keep the lookup operation const and use const casting at the dm_ function level.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4
--- LVM2/libdm/libdm-config.c 2011/08/31 15:19:20 1.3
+++ LVM2/libdm/libdm-config.c 2011/09/01 14:02:05 1.4
@@ -809,8 +809,8 @@
/*
* utility functions
*/
-static struct dm_config_node *_find_config_node(const void *start,
- const char *path)
+static const struct dm_config_node *_find_config_node(const void *start,
+ const char *path)
{
const char *e;
const struct dm_config_node *cn = start;
@@ -848,15 +848,15 @@
path = e;
}
- return (struct dm_config_node *) cn_found;
+ return cn_found;
}
-typedef struct dm_config_node *_node_lookup_fn(const void *start, const char *path);
+typedef const struct dm_config_node *_node_lookup_fn(const void *start, const char *path);
-static struct dm_config_node *_find_first_config_node(const void *start, const char *path)
+static const struct dm_config_node *_find_first_config_node(const void *start, const char *path)
{
const struct dm_config_tree *cft = start;
- struct dm_config_node *cn = NULL;
+ const struct dm_config_node *cn = NULL;
while (cft) {
if ((cn = _find_config_node(cft->root, path)))
@@ -976,7 +976,7 @@
struct dm_config_node *dm_config_find_node(struct dm_config_node *cn,
const char *path)
{
- return _find_config_node(cn, path);
+ return (struct dm_config_node *) _find_config_node(cn, path);
}
int dm_config_find_int(const struct dm_config_node *cn, const char *path, int fail)
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-02-28 17:46 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-11 15:18 LVM2/libdm libdm-config.c mornfall
-- strict thread matches above, loose matches on Subject: below --
2012-02-28 17:46 agk
2012-01-23 17:47 agk
2012-01-19 15:16 zkabelac
2011-09-25 19:45 zkabelac
2011-09-25 19:43 zkabelac
2011-09-25 19:42 zkabelac
2011-09-25 19:41 zkabelac
2011-09-25 19:40 zkabelac
2011-09-25 19:39 zkabelac
2011-09-01 14:02 zkabelac
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).