1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 01:55:10 +03:00

Deal with some more compiler warnings. Hope this doesn't break anything...

This commit is contained in:
Alasdair Kergon 2007-04-27 14:52:41 +00:00
parent 30b95041de
commit 8d2b0f24d3
6 changed files with 25 additions and 23 deletions

View File

@ -1,5 +1,6 @@
Version 1.02.19 -
====================================
Deal with some more compiler warnings.
Introduce _add_field() and _is_same_field() to libdm-report.c.
Fix some libdevmapper-event and dmeventd memory leaks.
Remove unnecessary memset() return value checks.

View File

@ -68,14 +68,14 @@ static struct dm_hash_node *_create_node(const char *str, unsigned len)
return n;
}
static unsigned long _hash(const unsigned char *str, unsigned len)
static unsigned long _hash(const char *str, unsigned len)
{
unsigned long h = 0, g;
unsigned i;
for (i = 0; i < len; i++) {
h <<= 4;
h += _nums[*str++];
h += _nums[(unsigned char) *str++];
g = h & ((unsigned long) 0xf << 16u);
if (g) {
h ^= g >> 16u;

View File

@ -433,12 +433,12 @@ static int _dm_task_get_info_v1(struct dm_task *dmt, struct dm_info *info)
return 1;
}
static const char *_dm_task_get_name_v1(struct dm_task *dmt)
static const char *_dm_task_get_name_v1(const struct dm_task *dmt)
{
return (dmt->dmi.v1->name);
}
static const char *_dm_task_get_uuid_v1(struct dm_task *dmt)
static const char *_dm_task_get_uuid_v1(const struct dm_task *dmt)
{
return (dmt->dmi.v1->uuid);
}
@ -924,7 +924,7 @@ int dm_task_get_info(struct dm_task *dmt, struct dm_info *info)
return 1;
}
const char *dm_task_get_name(struct dm_task *dmt)
const char *dm_task_get_name(const struct dm_task *dmt)
{
#ifdef DM_COMPAT
if (_dm_version == 1)
@ -934,7 +934,7 @@ const char *dm_task_get_name(struct dm_task *dmt)
return (dmt->dmi.v4->name);
}
const char *dm_task_get_uuid(struct dm_task *dmt)
const char *dm_task_get_uuid(const struct dm_task *dmt)
{
#ifdef DM_COMPAT
if (_dm_version == 1)
@ -1555,7 +1555,7 @@ static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
dmi->flags |= DM_SKIP_BDGET_FLAG;
log_debug("dm %s %s %s%s%s %s%.0d%s%.0d%s"
"%s%c%c%s %.0llu %s [%u]",
"%s%c%c%s %.0" PRIu64 " %s [%u]",
_cmd_data_v4[dmt->type].name,
dmi->name, dmi->uuid, dmt->newname ? " " : "",
dmt->newname ? dmt->newname : "",

View File

@ -133,8 +133,8 @@ struct dm_versions {
int dm_get_library_version(char *version, size_t size);
int dm_task_get_driver_version(struct dm_task *dmt, char *version, size_t size);
int dm_task_get_info(struct dm_task *dmt, struct dm_info *dmi);
const char *dm_task_get_name(struct dm_task *dmt);
const char *dm_task_get_uuid(struct dm_task *dmt);
const char *dm_task_get_name(const struct dm_task *dmt);
const char *dm_task_get_uuid(const struct dm_task *dmt);
struct dm_deps *dm_task_get_deps(struct dm_task *dmt);
struct dm_names *dm_task_get_names(struct dm_task *dmt);

View File

@ -117,7 +117,7 @@ int dm_snprintf(char *buf, size_t bufsize, const char *format, ...)
n = vsnprintf(buf, bufsize, format, ap);
va_end(ap);
if (n < 0 || (n > bufsize - 1))
if (n < 0 || ((unsigned) n + 1 > bufsize))
return -1;
return n;

View File

@ -749,7 +749,7 @@ static int _error_device(int argc __attribute((unused)), char **argv __attribute
if (!_set_task_device(dmt, name, 0))
goto error;
if (!dm_task_add_target(dmt, 0, size, "error", ""))
if (!dm_task_add_target(dmt, UINT64_C(0), size, "error", ""))
goto error;
if (_switches[READ_ONLY] && !dm_task_set_ro(dmt))
@ -1261,10 +1261,10 @@ static void _out_char(const unsigned c)
}
}
static void _out_string(const unsigned char *str)
static void _out_string(const char *str)
{
while (*str)
_out_char(*str++);
_out_char((unsigned char) *str++);
}
/* non-negative integers only */
@ -1502,7 +1502,7 @@ static int _dm_name_disp(struct dm_report *rh,
struct dm_report_field *field, const void *data,
void *private __attribute((unused)))
{
const char *name = dm_task_get_name((struct dm_task *) data);
const char *name = dm_task_get_name((const struct dm_task *) data);
return dm_report_field_string(rh, field, &name);
}
@ -1512,7 +1512,7 @@ static int _dm_uuid_disp(struct dm_report *rh,
struct dm_report_field *field,
const void *data, void *private __attribute((unused)))
{
const char *uuid = dm_task_get_uuid((struct dm_task *) data);
const char *uuid = dm_task_get_uuid((const struct dm_task *) data);
if (!uuid || !*uuid)
uuid = "";
@ -1527,7 +1527,7 @@ static int _dm_info_status_disp(struct dm_report *rh,
{
char buf[5];
const char *s = buf;
struct dm_info *info = (struct dm_info *) data;
const struct dm_info *info = data;
buf[0] = info->live_table ? 'L' : '-';
buf[1] = info->inactive_table ? 'I' : '-';
@ -1767,7 +1767,7 @@ static int _process_tree_options(const char *options)
{
const char *s, *end;
struct winsize winsz;
int len;
size_t len;
/* Symbol set default */
if (!strcmp(nl_langinfo(CODESET), "UTF-8"))
@ -1823,7 +1823,7 @@ static int _process_tree_options(const char *options)
/* Truncation doesn't work well with vt100 drawing char */
if (_tsym != &_tsym_vt100)
if (ioctl(1, TIOCGWINSZ, &winsz) >= 0 && winsz.ws_col > 3)
if (ioctl(1, (unsigned long) TIOCGWINSZ, &winsz) >= 0 && winsz.ws_col > 3)
_termwidth = winsz.ws_col - 3;
return 1;
@ -1860,13 +1860,13 @@ static char *parse_loop_device_name(char *dev)
if (strncmp(device, DEV_PATH, strlen(DEV_PATH)))
goto error;
strncpy(buf, strrchr(device, '/') + 1, PATH_MAX);
strncpy(buf, strrchr(device, '/') + 1, (size_t) PATH_MAX);
dm_free(device);
} else {
/* check for device number */
if (!strncmp(dev, "loop", strlen("loop")))
strncpy(buf, dev, PATH_MAX);
strncpy(buf, dev, (size_t) PATH_MAX);
else
goto error;
}
@ -1909,8 +1909,9 @@ static int _loop_table(char *table, size_t tlen, char *file,
sectors = size >> SECTOR_SHIFT;
if (_switches[VERBOSE_ARG])
fprintf(stderr, "losetup: set loop size to %llukB (%llu sectors)\n",
sectors >> 1, sectors);
fprintf(stderr, "losetup: set loop size to %llukB "
"(%llu sectors)\n", (long long unsigned) sectors >> 1,
(long long unsigned) sectors);
#ifdef HAVE_SYS_STATVFS_H
if (fstatvfs(fd, &fsbuf))
@ -2034,7 +2035,7 @@ static int _process_losetup_switches(const char *base, int *argc, char ***argv)
/* FIXME Missing free */
_table = dm_malloc(LOOP_TABLE_SIZE);
if (!_loop_table(_table, LOOP_TABLE_SIZE, loop_file, device_name, offset)) {
if (!_loop_table(_table, (size_t) LOOP_TABLE_SIZE, loop_file, device_name, offset)) {
fprintf(stderr, "Could not build device-mapper table for %s\n", (*argv)[0]);
dm_free(device_name);
return 0;