master - cleanup: use proper const in apply_lvname_restrictions
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=575c4ed96412ed...
Commit: 575c4ed96412edf513dbd0263983520a15b3b8bc
Parent: 21f6511bc200af434fb933a181f5334021b3ee08
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 14 14:03:58 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Dec 15 14:57:40 2012 +0100
cleanup: use proper const in apply_lvname_restrictions
Better constness used for reserved prefixes and strings.
Also simplify a bit validate_name and use direct char
checks isntead of 2 strcmp() calls.
---
lib/misc/lvm-string.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/misc/lvm-string.c b/lib/misc/lvm-string.c
index 7e4bbdd..9dcdb3d 100644
--- a/lib/misc/lvm-string.c
+++ b/lib/misc/lvm-string.c
@@ -81,7 +81,7 @@ int validate_name(const char *n)
if (*n == '-')
return 0;
- if (!strcmp(n, ".") || !strcmp(n, ".."))
+ if ((*n == '.') && (!n[1] || (n[1] == '.' && !n[2]))) /* ".", ".." */
return 0;
while ((len++, c = *n++))
@@ -96,13 +96,13 @@ int validate_name(const char *n)
int apply_lvname_restrictions(const char *name)
{
- const char *reserved_prefixes[] = {
+ static const char * const _reserved_prefixes[] = {
"snapshot",
"pvmove",
NULL
};
- const char *reserved_strings[] = {
+ static const char * const _reserved_strings[] = {
"_mlog",
"_mimage",
"_rimage",
@@ -116,7 +116,7 @@ int apply_lvname_restrictions(const char *name)
unsigned i;
const char *s;
- for (i = 0; (s = reserved_prefixes[i]); i++) {
+ for (i = 0; (s = _reserved_prefixes[i]); i++) {
if (!strncmp(name, s, strlen(s))) {
log_error("Names starting \"%s\" are reserved. "
"Please choose a different LV name.", s);
@@ -124,7 +124,7 @@ int apply_lvname_restrictions(const char *name)
}
}
- for (i = 0; (s = reserved_strings[i]); i++) {
+ for (i = 0; (s = _reserved_strings[i]); i++) {
if (strstr(name, s)) {
log_error("Names including \"%s\" are reserved. "
"Please choose a different LV name.", s);
11 years, 4 months
master - cleanup: reorder code
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=21f6511bc200af...
Commit: 21f6511bc200af434fb933a181f5334021b3ee08
Parent: 13835d04ac2a2c518ec935d220c7feb711327884
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 14 19:43:42 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Dec 15 14:57:40 2012 +0100
cleanup: reorder code
Swap if() test condition and check for failure
and use traditional 'stack' trace.
---
lib/format_text/format-text.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index b562cfa..476d5d9 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -2226,11 +2226,12 @@ static struct format_instance *_text_create_text_instance(const struct format_ty
if (!(fid = alloc_fid(fmt, fic)))
return_NULL;
- if (_create_vg_text_instance(fid, fic))
- return fid;
+ if (!_create_vg_text_instance(fid, fic)) {
+ dm_pool_destroy(fid->mem);
+ return_NULL;
+ }
- dm_pool_destroy(fid->mem);
- return NULL;
+ return fid;
}
static struct format_handler _text_handler = {
11 years, 4 months
master - cleanup: skip assignment
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=13835d04ac2a2c...
Commit: 13835d04ac2a2c518ec935d220c7feb711327884
Parent: 0396ade38b88431d959ce02fac689306a2c47786
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 14 14:18:46 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Dec 15 14:57:40 2012 +0100
cleanup: skip assignment
env is reassigned without the use, so drop this assign.
---
libdm/libdm-common.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index 075fba8..4a0ada8 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -87,7 +87,7 @@ void dm_lib_init(void)
{
const char *env;
- if ((env = getenv("DM_DISABLE_UDEV")))
+ if (getenv("DM_DISABLE_UDEV"))
_udev_disabled = 1;
env = getenv(DM_DEFAULT_NAME_MANGLING_MODE_ENV_VAR_NAME);
11 years, 4 months
master - cleanup: simplify option matching function
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0396ade38b8843...
Commit: 0396ade38b88431d959ce02fac689306a2c47786
Parent: a266154e1fc598ae184780391dc8d8e87eb2c891
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 14 16:41:24 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Dec 15 14:57:40 2012 +0100
cleanup: simplify option matching function
Avoid using sprintf and strncmp call, when
we really want to compare just one character.
---
tools/lvm.c | 17 +++++------------
1 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/tools/lvm.c b/tools/lvm.c
index 425549a..ec9674e 100644
--- a/tools/lvm.c
+++ b/tools/lvm.c
@@ -91,18 +91,11 @@ static char *_list_args(const char *text, int state)
return NULL;
/* Short form arguments */
- if (len < 3) {
- while (match_no < com->num_args) {
- char s[3];
- char c;
- if (!(c = (_cmdline->arg_props +
- com->valid_args[match_no++])->short_arg))
- continue;
-
- sprintf(s, "-%c", c);
- if (!strncmp(text, s, len))
- return strdup(s);
- }
+ if (len == 2 && text[0] == '-') {
+ while (match_no < com->num_args)
+ if (text[1] == (_cmdline->arg_props +
+ com->valid_args[match_no++])->short_arg)
+ return strdup(text);
}
/* Long form arguments */
11 years, 4 months
master - cleanup: singlenode minor change
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a266154e1fc598...
Commit: a266154e1fc598ae184780391dc8d8e87eb2c891
Parent: 8ab43345051fe49b1d56771383feb65c408eaf9a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 14 14:01:19 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Dec 15 14:57:40 2012 +0100
cleanup: singlenode minor change
Use strcpy instead of sprintf for plain string.
And use dm_strncpy for safer strncpy.
TODO: Fix API return values for cluster functions.
---
daemons/clvmd/clvmd-singlenode.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/daemons/clvmd/clvmd-singlenode.c b/daemons/clvmd/clvmd-singlenode.c
index 3b35bf5..b968c5f 100644
--- a/daemons/clvmd/clvmd-singlenode.c
+++ b/daemons/clvmd/clvmd-singlenode.c
@@ -136,7 +136,7 @@ static int _csid_from_name(char *csid, const char *name)
static int _name_from_csid(const char *csid, char *name)
{
- sprintf(name, "SINGLENODE");
+ strcpy(name, "SINGLENODE");
return 0;
}
@@ -284,9 +284,8 @@ static int _cluster_send_message(const void *buf, int msglen,
static int _get_cluster_name(char *buf, int buflen)
{
- strncpy(buf, "localcluster", buflen);
- buf[buflen - 1] = 0;
- return 0;
+ /* FIXME - cluster_ops API is broken - swap 1/0 */
+ return dm_strncpy(buf, "localcluster", buflen) ? 0 : 1;
}
static struct cluster_ops _cluster_singlenode_ops = {
11 years, 4 months
master - cleanup: ignore return values
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8ab43345051fe4...
Commit: 8ab43345051fe49b1d56771383feb65c408eaf9a
Parent: 1b05438fcbb27ba425c369c0b9d4e641ccc1b970
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 14 18:58:18 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Dec 15 14:57:40 2012 +0100
cleanup: ignore return values
These dm_snprintfs should not fail, since enough space is reserved.
So return intentionaly ignored.
---
lib/cache/lvmetad.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index a636f43..3ce2804 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -618,7 +618,7 @@ static int _extract_mda(struct metadata_area *mda, void *baton)
if (!mda->ops->mda_export_text) /* do nothing */
return 1;
- dm_snprintf(id, 32, "mda%d", b->i);
+ (void) dm_snprintf(id, 32, "mda%d", b->i);
if (!(cn = make_config_node(b->cft, id, b->cft->root, b->pre_sib)))
return 0;
if (!mda->ops->mda_export_text(mda, b->cft, cn))
@@ -639,7 +639,7 @@ static int _extract_da(struct disk_locn *da, void *baton)
if (!da)
return 1;
- dm_snprintf(id, 32, "da%d", b->i);
+ (void) dm_snprintf(id, 32, "da%d", b->i);
if (!(cn = make_config_node(b->cft, id, b->cft->root, b->pre_sib)))
return 0;
if (!config_make_nodes(b->cft, cn, NULL,
11 years, 4 months
master - cleanup: ignore errors
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1b05438fcbb27b...
Commit: 1b05438fcbb27ba425c369c0b9d4e641ccc1b970
Parent: 8b8065a870591e743a79e9aa7f738d084d88bcad
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 13 19:55:33 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Dec 15 14:57:40 2012 +0100
cleanup: ignore errors
Since we are doing just dump and function doesn't report
any error, explicitely ignore return values from
dm_config_write_node and dm_asprintf.
Same applies for the logging function.
---
daemons/lvmetad/lvmetad-core.c | 6 +++---
libdaemon/server/daemon-log.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 0a1c884..e1cb583 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -950,7 +950,7 @@ static void _dump_cft(struct buffer *buf, struct dm_hash_table *ht, const char *
struct dm_config_tree *cft = dm_hash_get_data(ht, n);
const char *key_backup = cft->root->key;
cft->root->key = dm_config_find_str(cft->root, key_addr, "unknown");
- dm_config_write_node(cft->root, buffer_line, buf);
+ (void) dm_config_write_node(cft->root, buffer_line, buf);
cft->root->key = key_backup;
n = dm_hash_get_next(ht, n);
}
@@ -969,9 +969,9 @@ static void _dump_pairs(struct buffer *buf, struct dm_hash_table *ht, const char
*val = dm_hash_get_data(ht, n);
buffer_append(buf, " ");
if (int_key)
- dm_asprintf(&append, "%d = \"%s\"", *(int*)key, val);
+ (void) dm_asprintf(&append, "%d = \"%s\"", *(int*)key, val);
else
- dm_asprintf(&append, "%s = \"%s\"", key, val);
+ (void) dm_asprintf(&append, "%s = \"%s\"", key, val);
if (append)
buffer_append(buf, append);
buffer_append(buf, "\n");
diff --git a/libdaemon/server/daemon-log.c b/libdaemon/server/daemon-log.c
index 6f5f4dc..c9e133c 100644
--- a/libdaemon/server/daemon-log.c
+++ b/libdaemon/server/daemon-log.c
@@ -98,7 +98,7 @@ void daemon_log_cft(log_state *s, int type, const char *prefix, const struct dm_
if (!_type_interesting(s, type))
return;
- dm_config_write_node(n, &_log_line, &b);
+ (void) dm_config_write_node(n, &_log_line, &b);
}
void daemon_log_multi(log_state *s, int type, const char *prefix, const char *msg)
11 years, 4 months
master - cleanup: drop unused header
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8b8065a870591e...
Commit: 8b8065a870591e743a79e9aa7f738d084d88bcad
Parent: 1d774e56670cd8b9d753a8f8a98a3d258e9ee912
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 13 20:35:00 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Dec 15 14:57:40 2012 +0100
cleanup: drop unused header
This header does not resolve any symbols here.
---
tools/toollib.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 1c455ef..669d772 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -15,7 +15,6 @@
#include "tools.h"
#include <sys/stat.h>
-#include <strings.h>
const char *command_name(struct cmd_context *cmd)
{
11 years, 4 months
master - cleanup: drop test for optarg NULL
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1d774e56670cd8...
Commit: 1d774e56670cd8b9d753a8f8a98a3d258e9ee912
Parent: 03be45ac0a3b10807374ac0869ac8431bee348b7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 13 19:54:07 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Dec 15 14:57:40 2012 +0100
cleanup: drop test for optarg NULL
Since -d takes an argument, we do not need to check for
optarg being NULL here.
---
daemons/clvmd/clvmd.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index eb0bffd..398e1a4 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -385,7 +385,7 @@ int main(int argc, char *argv[])
case 'd':
debug_opt = DEBUG_STDERR;
- debug_arg = optarg ? (debug_t) atoi(optarg) : DEBUG_STDERR;
+ debug_arg = (debug_t) atoi(optarg);
if (debug_arg == DEBUG_STDERR)
foreground_mode = 1;
break;
11 years, 4 months
master - cleanup: convert to 32bit
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=03be45ac0a3b10...
Commit: 03be45ac0a3b10807374ac0869ac8431bee348b7
Parent: 0958905b1bc0a59d34a4092377bae7c59f424181
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 13 20:35:38 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Dec 15 14:57:39 2012 +0100
cleanup: convert to 32bit
Chunk sizes fits into 4G range, so keep it in 32bit range.
---
tools/toollib.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 1d67e5d..1c455ef 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1618,7 +1618,7 @@ int update_pool_params(struct cmd_context *cmd, unsigned attr,
(2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE *
(SECTOR_SIZE / UINT64_C(64)));
log_warn("WARNING: Chunk size is too small for pool, suggested minimum is %s.",
- display_size(cmd, 1 << (ffs(estimate_chunk_size) + 1)));
+ display_size(cmd, 1 << (int)(ffs(estimate_chunk_size) + 1)));
}
/* Round up to extent size */
11 years, 4 months