Btrfs-progs: fix several complie warning

This patch fixed the following warning:
cmds-send.c:464:6: warning: ‘ret' may be used uninitialized in this function [-Wuninitialized]
crc32c.c:121:1: warning: control reaches end of non-void function [-Wreturn-type]
send-utils.c:69:11: warning: ‘comp' may be used uninitialized in this function [-Wuninitialized]
send-utils.c:126:6: warning: ‘comp' may be used uninitialized in this function [-Wuninitialized]
send-utils.c:99:22: warning: ‘entry' may be used uninitialized in this function [-Wuninitialized]
btrfs.c:261:2: warning: implicit declaration of function ‘crc32c_optimization_init' [-Wimplicit-function-declaration]
btrfs.c:105:2: warning: ‘cmd' may be used uninitialized in this function [-Wuninitialized]
restore.c:435:12: warning: ignoring return value of ‘ftruncate', declared with attribute warn_unused_result [-Wunused-result]

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
This commit is contained in:
Miao Xie 2012-08-10 10:46:16 +08:00 committed by root
parent d88f33152f
commit 3b4e2d6196
6 changed files with 16 additions and 7 deletions

View File

@ -19,6 +19,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "crc32c.h"
#include "commands.h" #include "commands.h"
#include "version.h" #include "version.h"
@ -93,7 +94,7 @@ static int parse_one_token(const char *arg, const struct cmd_group *grp,
static const struct cmd_struct * static const struct cmd_struct *
parse_command_token(const char *arg, const struct cmd_group *grp) parse_command_token(const char *arg, const struct cmd_group *grp)
{ {
const struct cmd_struct *cmd; const struct cmd_struct *cmd = NULL;
switch(parse_one_token(arg, grp, &cmd)) { switch(parse_one_token(arg, grp, &cmd)) {
case -1: case -1:

View File

@ -495,6 +495,7 @@ int cmd_send_start(int argc, char **argv)
subvol = realpath(argv[optind], NULL); subvol = realpath(argv[optind], NULL);
if (!subvol) { if (!subvol) {
ret = -errno;
fprintf(stderr, "ERROR: unable to resolve %s\n", argv[optind]); fprintf(stderr, "ERROR: unable to resolve %s\n", argv[optind]);
goto out; goto out;
} }
@ -519,6 +520,7 @@ int cmd_send_start(int argc, char **argv)
for (i = optind; i < argc; i++) { for (i = optind; i < argc; i++) {
subvol = realpath(argv[i], NULL); subvol = realpath(argv[i], NULL);
if (!subvol) { if (!subvol) {
ret = -errno;
fprintf(stderr, "ERROR: unable to resolve %s\n", argv[i]); fprintf(stderr, "ERROR: unable to resolve %s\n", argv[i]);
goto out; goto out;
} }

View File

@ -113,7 +113,7 @@ void crc32c_intel_probe(void)
} }
} }
int crc32c_optimization_init(void) void crc32c_optimization_init(void)
{ {
crc32c_intel_probe(); crc32c_intel_probe();
if (crc32c_intel_available) if (crc32c_intel_available)
@ -121,7 +121,7 @@ int crc32c_optimization_init(void)
} }
#else #else
int crc32c_optimization_init(void) void crc32c_optimization_init(void)
{ {
} }

View File

@ -22,7 +22,7 @@
#include "kerncompat.h" #include "kerncompat.h"
u32 crc32c_le(u32 seed, unsigned char const *data, size_t length); u32 crc32c_le(u32 seed, unsigned char const *data, size_t length);
int crc32c_optimization_init(void); void crc32c_optimization_init(void);
#define crc32c(seed, data, length) crc32c_le(seed, (unsigned char const *)data, length) #define crc32c(seed, data, length) crc32c_le(seed, (unsigned char const *)data, length)
#define btrfs_crc32c crc32c #define btrfs_crc32c crc32c

View File

@ -385,7 +385,6 @@ static int copy_file(struct btrfs_root *root, int fd, struct btrfs_key *key,
/* No more leaves to search */ /* No more leaves to search */
btrfs_free_path(path); btrfs_free_path(path);
goto set_size; goto set_size;
return 0;
} }
leaf = path->nodes[0]; leaf = path->nodes[0];
} while (!leaf); } while (!leaf);
@ -431,8 +430,11 @@ next:
btrfs_free_path(path); btrfs_free_path(path);
set_size: set_size:
if (found_size) if (found_size) {
ftruncate(fd, (loff_t)found_size); ret = ftruncate(fd, (loff_t)found_size);
if (ret)
return ret;
}
return 0; return 0;
} }

View File

@ -62,6 +62,8 @@ static struct rb_node *tree_insert(struct rb_root *root,
entry = rb_entry(parent, struct subvol_info, entry = rb_entry(parent, struct subvol_info,
rb_path_node); rb_path_node);
comp = strcmp(entry->path, si->path); comp = strcmp(entry->path, si->path);
} else {
BUG();
} }
if (comp < 0) if (comp < 0)
@ -120,6 +122,8 @@ static struct subvol_info *tree_search(struct rb_root *root,
} else if (type == subvol_search_by_path) { } else if (type == subvol_search_by_path) {
entry = rb_entry(n, struct subvol_info, rb_path_node); entry = rb_entry(n, struct subvol_info, rb_path_node);
comp = strcmp(entry->path, path); comp = strcmp(entry->path, path);
} else {
BUG();
} }
if (comp < 0) if (comp < 0)
n = n->rb_left; n = n->rb_left;