1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

build: fix x32 arch

This patch fixed lvm2 compilation running on x32 arch.
(Using 64bit x86 cpu features but running on 32b address space,
so consuming less mem in VM).

On x32 arch 'time_t' is 64bit while 'long' is 32bit.
This commit is contained in:
Mikulas Patocka 2017-02-15 11:01:49 -05:00 committed by Zdenek Kabelac
parent 36cac41115
commit 78d004efa8
3 changed files with 8 additions and 8 deletions

View File

@ -128,8 +128,8 @@ int import_pv(const struct format_type *fmt, struct dm_pool *mem,
int generate_lvm1_system_id(struct cmd_context *cmd, char *s, const char *prefix)
{
if (dm_snprintf(s, NAME_LEN, "%s%s%lu",
prefix, cmd->hostname, time(NULL)) < 0) {
if (dm_snprintf(s, NAME_LEN, "%s%s" FMTu64,
prefix, cmd->hostname, (uint64_t)time(NULL)) < 0) {
log_error("Generated LVM1 format system_id too long");
return 0;
}

View File

@ -350,7 +350,7 @@ static int _print_header(struct cmd_context *cmd, struct formatter *f,
_utsname.version, _utsname.machine);
if (cmd->system_id && *cmd->system_id)
outf(f, "creation_host_system_id = \"%s\"", cmd->system_id);
outf(f, "creation_time = %lu\t# %s", t, ctime(&t));
outf(f, "creation_time = " FMTu64 "\t# %s", (uint64_t)t, ctime(&t));
return 1;
}

View File

@ -1008,7 +1008,7 @@ static int _translate_time_items(struct dm_report *rh, struct time_info *info,
dm_pool_free(info->mem, info->ti_list);
info->ti_list = NULL;
if (dm_snprintf(buf, sizeof(buf), "@%ld:@%ld", t1, t2) == -1) {
if (dm_snprintf(buf, sizeof(buf), "@" FMTd64 ":@" FMTd64, (int64_t)t1, (int64_t)t2) == -1) {
log_error("_translate_time_items: dm_snprintf failed");
return 0;
}
@ -1063,10 +1063,10 @@ static void *_lv_time_handler_get_dynamic_value(struct dm_report *rh,
struct dm_pool *mem,
const char *data_in)
{
time_t t1, t2;
int64_t t1, t2;
time_t *result;
if (sscanf(data_in, "@%ld:@%ld", &t1, &t2) != 2) {
if (sscanf(data_in, "@" FMTd64 ":@" FMTd64, &t1, &t2) != 2) {
log_error("Failed to get value for parsed time specification.");
return NULL;
}
@ -1076,8 +1076,8 @@ static void *_lv_time_handler_get_dynamic_value(struct dm_report *rh,
return NULL;
}
result[0] = t1;
result[1] = t2;
result[0] = (time_t) t1; /* Validate range for 32b arch ? */
result[1] = (time_t) t2;
return result;
}