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.
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;
}
_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;
}
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;
}
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;
}
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;
}