1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-12 13:52:28 +03:00

gcc: correct signess comparation

Compare int to int and unsigned to unsigned...
This commit is contained in:
Zdenek Kabelac 2023-07-13 12:32:44 +02:00
parent 64b28e0839
commit 5ce236a691
23 changed files with 82 additions and 78 deletions

View File

@ -67,7 +67,7 @@ struct log_c {
uint32_t recoverer;
uint64_t recovering_region; /* -1 means not recovering */
uint64_t skip_bit_warning; /* used to warn if region skipped */
int sync_search;
unsigned sync_search;
int resume_override;
@ -220,7 +220,7 @@ static int rw_log(struct log_c *lc, int do_write)
if (r < 0)
LOG_ERROR("[%s] rw_log: read failure: %s",
SHORT_UUID(lc->uuid), strerror(errno));
if (r != lc->disk_size)
if ((unsigned) r != lc->disk_size)
return -EIO; /* Failed disk read */
return 0;
}
@ -298,7 +298,7 @@ static int find_disk_path(char *major_minor_str, char *path_rtn, int *unlink_pat
DIR *dp;
struct dirent *dep;
struct stat statbuf;
int major, minor;
unsigned major, minor;
if (!strstr(major_minor_str, ":")) {
r = stat(major_minor_str, &statbuf);

View File

@ -5280,7 +5280,7 @@ static int match_dm_uuid(char *dm_uuid, char *lv_lock_uuid)
{
char buf1[64];
char buf2[64];
int i, j;
unsigned i, j;
memset(buf1, 0, sizeof(buf1));
memset(buf2, 0, sizeof(buf2));
@ -6280,9 +6280,8 @@ int main(int argc, char *argv[])
.daemon_fini = NULL,
.daemon_main = main_loop,
};
daemon_host_id_file = NULL;
static struct option long_options[] = {
static const struct option long_options[] = {
{"help", no_argument, 0, 'h' },
{"version", no_argument, 0, 'V' },
{"test", no_argument, 0, 'T' },
@ -6300,6 +6299,8 @@ int main(int argc, char *argv[])
{0, 0, 0, 0 }
};
daemon_host_id_file = NULL;
while (1) {
int c;
int lm;

View File

@ -4132,7 +4132,7 @@ int get_crypt_table_offset(dev_t crypt_devt, uint32_t *offset_bytes)
char offset_str[32] = { 0 };
int copy_offset = 0;
int spaces = 0;
int i, i_off = 0;
unsigned i, i_off = 0;
if (!dmt)
return_0;

View File

@ -58,6 +58,7 @@ bool bcache_read_bytes(struct bcache *cache, int di, uint64_t start, size_t len,
block_address bb, be;
uint64_t block_size = bcache_block_sectors(cache) << SECTOR_SHIFT;
uint64_t block_offset = start % block_size;
size_t blen;
bcache_prefetch_bytes(cache, di, start, len);
@ -67,7 +68,7 @@ bool bcache_read_bytes(struct bcache *cache, int di, uint64_t start, size_t len,
if (!bcache_get(cache, di, bb, 0, &b))
return false;
size_t blen = _min(block_size - block_offset, len);
blen = _min(block_size - block_offset, len);
memcpy(data, ((unsigned char *) b->data) + block_offset, blen);
bcache_put(b);

View File

@ -53,7 +53,7 @@ static struct {
const char *dev_dir;
int has_scanned;
long st_dev;
dev_t st_dev;
struct dm_list dirs;
struct dm_list files;
@ -2123,10 +2123,10 @@ static char *_get_devname_from_devno(struct cmd_context *cmd, dev_t devno)
char devname[PATH_MAX] = { 0 };
char namebuf[NAME_LEN];
char line[1024];
int major = MAJOR(devno);
int minor = MINOR(devno);
int line_major;
int line_minor;
unsigned major = MAJOR(devno);
unsigned minor = MINOR(devno);
unsigned line_major;
unsigned line_minor;
uint64_t line_blocks;
DIR *dir;
struct dirent *dirent;

View File

@ -466,8 +466,8 @@ static int _dev_is_mpath_component_sysfs(struct cmd_context *cmd, struct device
struct dirent *de;
int dev_major = MAJOR(dev->dev);
int dev_minor = MINOR(dev->dev);
int dm_dev_major;
int dm_dev_minor;
unsigned dm_dev_major;
unsigned dm_dev_minor;
struct stat info;
int is_mpath_component = 0;
@ -539,8 +539,8 @@ static int _dev_is_mpath_component_sysfs(struct cmd_context *cmd, struct device
dev_name(dev), dm_dev_path, errno);
continue;
}
dm_dev_major = (int)MAJOR(info.st_rdev);
dm_dev_minor = (int)MINOR(info.st_rdev);
dm_dev_major = MAJOR(info.st_rdev);
dm_dev_minor = MINOR(info.st_rdev);
if (dm_dev_major != dt->device_mapper_major) {
log_debug_devs("dev_is_mpath_component %s holder %s %d:%d does not have dm major",
@ -767,7 +767,7 @@ const char *dev_mpath_component_wwid(struct cmd_context *cmd, struct device *dev
continue;
if (strstr(sysbuf, "scsi_debug")) {
int i;
unsigned i;
for (i = 0; i < strlen(sysbuf); i++) {
if (sysbuf[i] == ' ')
sysbuf[i] = '_';

View File

@ -89,7 +89,7 @@ int dev_is_used_by_active_lv(struct cmd_context *cmd, struct device *dev, int *u
DIR *d;
struct dirent *dirent;
char *holder_name;
int dm_dev_major, dm_dev_minor;
unsigned dm_dev_major, dm_dev_minor;
size_t lvm_prefix_len = sizeof(UUID_PREFIX) - 1;
size_t lvm_uuid_len = sizeof(UUID_PREFIX) - 1 + 2 * ID_LEN;
size_t uuid_len;

View File

@ -38,15 +38,15 @@ struct dev_type_def {
};
struct dev_types {
int md_major;
int blkext_major;
int drbd_major;
int device_mapper_major;
int emcpower_major;
int vxdmp_major;
int power2_major;
int dasd_major;
int loop_major;
unsigned md_major;
unsigned blkext_major;
unsigned drbd_major;
unsigned device_mapper_major;
unsigned emcpower_major;
unsigned vxdmp_major;
unsigned power2_major;
unsigned dasd_major;
unsigned loop_major;
struct dev_type_def dev_type_array[NUMBER_OF_MAJORS];
};

View File

@ -238,9 +238,9 @@ void dev_destroy_file(struct device *dev);
int dev_mpath_init(const char *config_wwids_file);
void dev_mpath_exit(void);
int parse_vpd_ids(const unsigned char *vpd_data, int vpd_datalen, struct dm_list *ids);
int format_t10_id(const unsigned char *in, int in_bytes, unsigned char *out, int out_bytes);
int format_general_id(const char *in, int in_bytes, unsigned char *out, int out_bytes);
int parse_vpd_serial(const unsigned char *in, char *out, int outsize);
int format_t10_id(const unsigned char *in, size_t in_bytes, unsigned char *out, size_t out_bytes);
int format_general_id(const char *in, size_t in_bytes, unsigned char *out, size_t out_bytes);
int parse_vpd_serial(const unsigned char *in, char *out, size_t outsize);
/* dev_util */
int device_id_list_remove(struct dm_list *devices, struct device *dev);

View File

@ -186,10 +186,10 @@ void free_dids(struct dm_list *ids)
}
/* More than one _ in a row is replaced with one _ */
static void _reduce_repeating_underscores(char *buf, int bufsize)
static void _reduce_repeating_underscores(char *buf, size_t bufsize)
{
char *tmpbuf;
int us = 0, i, j = 0;
unsigned us = 0, i, j = 0;
if (!(tmpbuf = strndup(buf, bufsize-1)))
return;
@ -216,10 +216,10 @@ static void _reduce_repeating_underscores(char *buf, int bufsize)
free(tmpbuf);
}
static void _remove_leading_underscores(char *buf, int bufsize)
static void _remove_leading_underscores(char *buf, size_t bufsize)
{
char *tmpbuf;
int i, j = 0;
unsigned i, j = 0;
if (buf[0] != '_')
return;
@ -492,7 +492,8 @@ int dev_read_sys_wwid(struct cmd_context *cmd, struct device *dev,
char buf[DEV_WWID_SIZE] = { 0 };
struct dev_wwid *dw;
int is_t10 = 0;
int i, ret;
int ret;
unsigned i;
dev->flags |= DEV_ADDED_SYS_WWID;
@ -566,7 +567,8 @@ static int _dev_read_sys_serial(struct cmd_context *cmd, struct device *dev,
char vdx[8] = { 0 };
const char *sysfs_dir;
const char *base;
int i, j = 0, ret;
unsigned i, j = 0;
int ret;
/* /dev/vda to vda */
base = basename(devname);
@ -603,7 +605,7 @@ const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, u
char sysbuf2[PATH_MAX] = { 0 };
const char *idname = NULL;
struct dev_wwid *dw;
int i;
unsigned i;
if (idtype == DEV_ID_TYPE_SYS_WWID) {
dev_read_sys_wwid(cmd, dev, sysbuf, sizeof(sysbuf), NULL);
@ -1767,7 +1769,7 @@ void device_id_update_vg_uuid(struct cmd_context *cmd, struct volume_group *vg,
unlock_devices_file(cmd);
}
static int _idtype_compatible_with_major_number(struct cmd_context *cmd, int idtype, int major)
static int _idtype_compatible_with_major_number(struct cmd_context *cmd, int idtype, unsigned major)
{
/* devname can be used with any kind of device */
if (idtype == DEV_ID_TYPE_DEVNAME)
@ -2983,8 +2985,8 @@ void device_ids_find_renamed_devs(struct cmd_context *cmd, struct dm_list *dev_l
* filter values.
*/
dm_list_iterate_items(devl, &search_devs) {
dev = devl->dev;
int has_pvid;
dev = devl->dev;
/*
* We only need to check devs that would use ID_TYPE_DEVNAME

View File

@ -288,7 +288,7 @@ int fs_mount_state_is_misnamed(struct cmd_context *cmd, struct logical_volume *l
* The mnt dir from /etc/mtab and /proc/mounts are compared below.
*/
if (strchr(mtab_mntpath, ' ')) {
int i, j = 0;
unsigned i, j = 0;
memcpy(tmp_path, mtab_mntpath, sizeof(tmp_path));
memset(mtab_mntpath, 0, sizeof(mtab_mntpath));
for (i = 0; i < sizeof(tmp_path); i++) {

View File

@ -41,13 +41,13 @@
* Replace each space with underscore.
* Skip quotes, non-ascii, non-printable.
*/
int format_general_id(const char *in, int in_bytes, unsigned char *out, int out_bytes)
int format_general_id(const char *in, size_t in_bytes, unsigned char *out, size_t out_bytes)
{
const char *end;
int end_bytes = strlen(in);
size_t end_bytes = strlen(in);
int retlen = 0;
int j = 0;
int i;
unsigned j = 0;
unsigned i;
if (!end_bytes)
return 0;
@ -88,12 +88,12 @@ int format_general_id(const char *in, int in_bytes, unsigned char *out, int out_
* Replace series of spaces with a single _.
* Skip quotes, non-ascii, non-printable.
*/
int format_t10_id(const unsigned char *in, int in_bytes, unsigned char *out, int out_bytes)
int format_t10_id(const unsigned char *in, size_t in_bytes, unsigned char *out, size_t out_bytes)
{
int in_space = 0;
int retlen = 0;
int j = 0;
int i;
unsigned j = 0;
unsigned i;
for (i = 0; i < in_bytes; i++) {
if (!in[i])
@ -168,7 +168,7 @@ int parse_vpd_ids(const unsigned char *vpd_data, int vpd_datalen, struct dm_list
case 0x1:
/* T10 Vendor ID */
cur_id_size = d[3];
if (cur_id_size + 4 > id_len)
if ((size_t)(cur_id_size + 4) > id_len)
cur_id_size = id_len - 4;
cur_id_str = d + 4;
format_t10_id(cur_id_str, cur_id_size, tmp_str, sizeof(tmp_str));
@ -253,7 +253,7 @@ int parse_vpd_ids(const unsigned char *vpd_data, int vpd_datalen, struct dm_list
* and if so does tolower() on the chars.
*/
if ((type == 2) || (type == 3)) {
int i;
unsigned i;
for (i = 0; i < strlen(id); i++)
id[i] = tolower(id[i]);
}
@ -267,9 +267,9 @@ int parse_vpd_ids(const unsigned char *vpd_data, int vpd_datalen, struct dm_list
return id_size;
}
int parse_vpd_serial(const unsigned char *in, char *out, int outsize)
int parse_vpd_serial(const unsigned char *in, char *out, size_t outsize)
{
uint8_t len_buf[2] __attribute__((aligned(8))) = { 0 };;
uint8_t len_buf[2] __attribute__((aligned(8))) = { 0 };
size_t len;
/* parsing code from multipath tools */

View File

@ -936,7 +936,8 @@ char yes_no_prompt(const char *prompt, ...)
static const char _no[] = "no";
const char *answer = NULL;
int c = silent_mode() ? EOF : 0;
int i = 0, ret = 0, sig = 0;
int ret = 0, sig = 0;
unsigned i = 0;
char buf[12];
va_list ap;

View File

@ -266,7 +266,7 @@ static bool _in_bcache(struct device *dev)
static struct labeller *_find_lvm_header(struct device *dev,
char *headers_buf,
int headers_buf_size,
size_t headers_buf_size,
uint64_t *label_sector,
uint64_t block_sector,
uint64_t start_sector)
@ -341,7 +341,7 @@ static struct labeller *_find_lvm_header(struct device *dev,
* are performed in the processing functions to get that data.
*/
static int _process_block(struct cmd_context *cmd, struct dev_filter *f,
struct device *dev, char *headers_buf, int headers_buf_size,
struct device *dev, char *headers_buf, size_t headers_buf_size,
uint64_t block_sector, uint64_t start_sector,
int *is_lvm_device)
{
@ -993,7 +993,7 @@ int label_scan_vg_online(struct cmd_context *cmd, const char *vgname,
struct pv_online *po;
struct device_list *devl, *devl2;
int relax_deviceid_filter = 0;
int metadata_pv_count;
unsigned metadata_pv_count;
int try_dev_scan = 0;
dm_list_init(&pvs_online);

View File

@ -547,7 +547,7 @@ static int _remove_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg)
return 1;
}
static int _extend_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg, int extend_mb)
static int _extend_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg, unsigned extend_mb)
{
struct device *dev;
char path[PATH_MAX];
@ -654,7 +654,7 @@ static int _refresh_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg)
int handle_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg)
{
daemon_reply reply;
int extend_mb;
unsigned extend_mb;
int result;
int ret;
@ -663,7 +663,7 @@ int handle_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg)
if (!_lvmlockd_connected)
return 0;
extend_mb = find_config_tree_int(cmd, global_sanlock_lv_extend_CFG, NULL);
extend_mb = (unsigned) find_config_tree_int(cmd, global_sanlock_lv_extend_CFG, NULL);
/*
* User can choose to not automatically extend the lvmlock LV

View File

@ -385,7 +385,7 @@ static int _set_integrity_block_size(struct cmd_context *cmd, struct logical_vol
*/
rv = fs_block_size_and_type(pathname, &fs_block_size, NULL, NULL);
if (!rv || !fs_block_size) {
int use_bs;
unsigned use_bs;
if (lbs_4k && pbs_4k) {
use_bs = 4096;

View File

@ -931,7 +931,7 @@ int validate_major_minor(const struct cmd_context *cmd,
} else {
/* 12 bits for major number */
if ((major != -1) &&
(major != cmd->dev_types->device_mapper_major)) {
(major != (int)cmd->dev_types->device_mapper_major)) {
/* User supplied some major number */
if (major < 0 || major > 4095) {
log_error("Major number %d outside range 0-4095.", major);

View File

@ -593,7 +593,7 @@ static int _get_memory_info(uint64_t *total_mb, uint64_t *available_mb)
if (!(e = strchr(line, ':')))
break;
if ((++e - line) > sizeof(namebuf))
if ((unsigned)(++e - line) > sizeof(namebuf))
continue; // something too long
(void)dm_strncpy((char*)findme.name, line, e - line);

View File

@ -69,7 +69,7 @@ void sigint_clear(void)
void sigint_allow(void)
{
int i, mask = 0;
unsigned i, mask = 0;
struct sigaction handler;
sigset_t sigs;
@ -110,7 +110,7 @@ void sigint_allow(void)
void sigint_restore(void)
{
int i, mask = 0;
unsigned i, mask = 0;
sigset_t sigs;
if (memlock_count_daemon())

View File

@ -2036,7 +2036,7 @@ static int _find_ancestors(struct _str_list_append_baton *ancestors,
struct lv_segment *seg;
void *orig_p = glv.live;
const char *ancestor_str;
char buf[NAME_LEN + strlen(HISTORICAL_LV_PREFIX) + 1];
char buf[NAME_LEN + sizeof(HISTORICAL_LV_PREFIX)];
if (glv.is_historical) {
if (full && glv.historical->indirect_origin)

View File

@ -2326,13 +2326,12 @@ static void _print_val_man(struct command_name *cname, int opt_enum, int val_enu
char *line_argv[MAX_LINE_ARGC];
int line_argc;
int i;
_was_hyphen = 0;
int is_relative_opt = (opt_enum == size_ARG) ||
(opt_enum == extents_ARG) ||
(opt_enum == poolmetadatasize_ARG) ||
(opt_enum == mirrors_ARG);
_was_hyphen = 0;
/*
* Suppress the [+] prefix for lvcreate which we have to
* accept for backwards compat, but don't want to advertise.
@ -2515,7 +2514,7 @@ static const char *_man_long_opt_name(const char *cmdname, int opt_enum)
{
static char long_opt_name[LONG_OPT_NAME_LEN];
const char *long_opt;
int i;
unsigned i;
memset(&long_opt_name, 0, sizeof(long_opt_name));

View File

@ -383,13 +383,13 @@ static bool _read_bytes(struct device *dev, struct devicefile *def, uint64_t sta
return false;
off = lseek(def->fd, start, SEEK_SET);
if (off != start)
if (off != (off_t)start)
return false;
rv = read(def->fd, data, len);
if (rv < 0)
return false;
if (rv != len)
if ((size_t)rv != len)
return false;
return true;
}
@ -418,7 +418,7 @@ static int _dump_all_text(struct cmd_context *cmd, struct settings *set, const c
int multiple_vgs = 0;
int bad_end;
int vgnamelen;
int count;
unsigned count;
int len;
if (tofile) {
@ -1859,8 +1859,8 @@ static int _get_settings(struct cmd_context *cmd, struct settings *set)
const char *str;
char key[64];
char val[64];
int num;
int pos;
unsigned num;
unsigned pos;
/*
* "grouped" means that multiple --settings options can be used.
@ -2119,7 +2119,7 @@ static int _check_for_mda2(struct cmd_context *cmd, struct device *dev,
char buf2[256];
char *buf;
uint64_t mda_offset, mda_size, extra_bytes; /* bytes */
int i, found = 0;
unsigned i, found = 0;
if (device_size < (2 * ONE_MB_IN_BYTES))
return_0;
@ -2833,7 +2833,7 @@ static int _dump_backup_to_raw(struct cmd_context *cmd, struct settings *set)
goto fail_close;
rv = read(fd, back_buf, back_size);
if (rv != back_size) {
if (rv != (int)back_size) {
log_error("Cannot read file: %s", input);
free(back_buf);
goto fail_close;
@ -2970,7 +2970,7 @@ static int _read_metadata_file(struct cmd_context *cmd, struct metadata_file *mf
goto_out;
rv = read(fd, text_buf, text_size);
if (rv != text_size) {
if (rv != (int)text_size) {
log_error("Cannot read file: %s", mf->filename);
free(text_buf);
goto out;

View File

@ -1524,7 +1524,7 @@ int get_writecache_settings(struct cmd_context *cmd, struct writecache_settings
char key[64];
char val[64];
int num;
int pos;
unsigned pos;
int rn;
int found = 0;
@ -1854,7 +1854,7 @@ int get_and_validate_major_minor(const struct cmd_context *cmd,
*major, cmd->dev_types->device_mapper_major);
}
/* Stay with dynamic major:minor if minor is not specified. */
*major = (*minor == -1) ? -1 : cmd->dev_types->device_mapper_major;
*major = (*minor == -1) ? -1 : (int)cmd->dev_types->device_mapper_major;
}
if ((*minor != -1) && !validate_major_minor(cmd, fmt, *major, *minor))