Fix remaining warnings and compile with -Wpointer-arith.
Version 2.02.85 -
===================================
+ Handle decimal digits with --units instead of ignoring them silently.
+ Fix remaining warnings and compile with -Wpointer-arith.
Fix gcc warnings for unused variables.
Add stack backtraces for error paths in process_each_lv().
Fixing some const cast gcc warnings in the code.
* The standard io loop that keeps submitting an io until it's
* all gone.
*---------------------------------------------------------------*/
-static int _io(struct device_area *where, void *buffer, int should_write)
+static int _io(struct device_area *where, char *buffer, int should_write)
{
int fd = dev_fd(where->dev);
ssize_t n = 0;
result->size += block_size - delta;
}
-static int _aligned_io(struct device_area *where, void *buffer,
+static int _aligned_io(struct device_area *where, char *buffer,
int should_write)
{
- void *bounce, *bounce_buf;
+ char *bounce, *bounce_buf;
unsigned int block_size = 0;
uintptr_t mask;
struct device_area widened;
* Realign start of bounce buffer (using the extra sector)
*/
if (((uintptr_t) bounce) & mask)
- bounce = (void *) ((((uintptr_t) bounce) + mask) & ~mask);
+ bounce = (char *) ((((uintptr_t) bounce) + mask) & ~mask);
/* channel the io through the bounce buffer */
if (!_io(&widened, bounce, 0)) {
* 'buf' should be len+len2.
*/
int dev_read_circular(struct device *dev, uint64_t offset, size_t len,
- uint64_t offset2, size_t len2, void *buf)
+ uint64_t offset2, size_t len2, char *buf)
{
if (!dev_read(dev, offset, len, buf)) {
log_error("Read from %s failed", dev_name(dev));
*/
/* FIXME pre-extend the file */
-int dev_append(struct device *dev, size_t len, void *buffer)
+int dev_append(struct device *dev, size_t len, char *buffer)
{
int r;
int dev_read(struct device *dev, uint64_t offset, size_t len, void *buffer);
int dev_read_circular(struct device *dev, uint64_t offset, size_t len,
- uint64_t offset2, size_t len2, void *buf);
+ uint64_t offset2, size_t len2, char *buf);
int dev_write(struct device *dev, uint64_t offset, size_t len, void *buffer);
-int dev_append(struct device *dev, size_t len, void *buffer);
+int dev_append(struct device *dev, size_t len, char *buffer);
int dev_set(struct device *dev, uint64_t offset, size_t len, int value);
void dev_flush(struct device *dev);
{
char *ptr = NULL;
uint64_t v;
+ double custom_value = 0;
+ uint64_t multiplier;
if (isdigit(*units)) {
- v = (uint64_t) strtod(units, &ptr);
+ custom_value = strtod(units, &ptr);
if (ptr == units)
return 0;
+ v = (uint64_t) strtoull(units, NULL, 10);
+ if ((double) v == custom_value)
+ custom_value = 0; /* Use integer arithmetic */
units = ptr;
} else
v = 1;
+ /* Only one units char permitted. */
+ if (*(units + 1))
+ return 0;
+
if (v == 1)
*unit_type = *units;
else
switch (*units) {
case 'h':
case 'H':
- v = UINT64_C(1);
+ multiplier = v = UINT64_C(1);
*unit_type = *units;
break;
case 'b':
case 'B':
- v *= UINT64_C(1);
+ multiplier = UINT64_C(1);
break;
#define KILO UINT64_C(1024)
case 's':
case 'S':
- v *= (KILO/2);
+ multiplier = (KILO/2);
break;
case 'k':
- v *= KILO;
+ multiplier = KILO;
break;
case 'm':
- v *= KILO * KILO;
+ multiplier = KILO * KILO;
break;
case 'g':
- v *= KILO * KILO * KILO;
+ multiplier = KILO * KILO * KILO;
break;
case 't':
- v *= KILO * KILO * KILO * KILO;
+ multiplier = KILO * KILO * KILO * KILO;
break;
case 'p':
- v *= KILO * KILO * KILO * KILO * KILO;
+ multiplier = KILO * KILO * KILO * KILO * KILO;
break;
case 'e':
- v *= KILO * KILO * KILO * KILO * KILO * KILO;
+ multiplier = KILO * KILO * KILO * KILO * KILO * KILO;
break;
#undef KILO
#define KILO UINT64_C(1000)
case 'K':
- v *= KILO;
+ multiplier = KILO;
break;
case 'M':
- v *= KILO * KILO;
+ multiplier = KILO * KILO;
break;
case 'G':
- v *= KILO * KILO * KILO;
+ multiplier = KILO * KILO * KILO;
break;
case 'T':
- v *= KILO * KILO * KILO * KILO;
+ multiplier = KILO * KILO * KILO * KILO;
break;
case 'P':
- v *= KILO * KILO * KILO * KILO * KILO;
+ multiplier = KILO * KILO * KILO * KILO * KILO;
break;
case 'E':
- v *= KILO * KILO * KILO * KILO * KILO * KILO;
+ multiplier = KILO * KILO * KILO * KILO * KILO * KILO;
break;
#undef KILO
default:
return 0;
}
- if (*(units + 1))
- return 0;
-
- return v;
+ if (custom_value)
+ return (uint64_t) (custom_value * multiplier);
+ else
+ return v * multiplier;
}
const char alloc_policy_char(alloc_policy_t alloc)
# define DM_EXISTS_FLAG 0x00000004
#endif
-static void *_align(void *ptr, unsigned int a)
+static char *_align(char *ptr, unsigned int a)
{
register unsigned long agn = --a;
- return (void *) (((unsigned long) ptr + agn) & ~agn);
+ return (char *) (((unsigned long) ptr + agn) & ~agn);
}
static int _uname(void)
dmt->dmi.v1->data_start);
}
-static void *_add_target_v1(struct target *t, void *out, void *end)
+static char *_add_target_v1(struct target *t, char *out, char *end)
{
- void *out_sp = out;
+ char *out_sp = out;
struct dm_target_spec_v1 sp;
size_t sp_size = sizeof(struct dm_target_spec_v1);
int len;
if ((out + len + 1) >= end)
return_NULL;
- strcpy((char *) out, t->params);
+ strcpy(out, t->params);
out += len + 1;
/* align next block */
struct dm_ioctl_v1 *dmi;
struct target *t;
size_t len = sizeof(struct dm_ioctl_v1);
- void *b, *e;
+ char *b, *e;
int count = 0;
for (t = dmt->head; t; t = t->next) {
dmi->target_count = count;
- b = (void *) (dmi + 1);
- e = (void *) ((char *) dmi + len);
+ b = (char *) (dmi + 1);
+ e = (char *) dmi + len;
for (t = dmt->head; t; t = t->next)
if (!(b = _add_target_v1(t, b, e))) {
names->dev = (uint64_t) buf.st_rdev;
names->next = 0;
len = strlen(name);
- if (((void *) (names + 1) + len + 1) >= end) {
+ if (((char *) (names + 1) + len + 1) >= end) {
log_error("Insufficient buffer space for device list");
r = 0;
break;
strcpy(names->name, name);
old_names = names;
- names = _align((void *) ++names + len + 1, ALIGNMENT);
+ names = _align((char *) ++names + len + 1, ALIGNMENT);
}
if (closedir(d))
return NULL;
}
-static void *_add_target(struct target *t, void *out, void *end)
+static char *_add_target(struct target *t, char *out, char *end)
{
- void *out_sp = out;
+ char *out_sp = out;
struct dm_target_spec sp;
size_t sp_size = sizeof(struct dm_target_spec);
int len;
if ((out + len + 1) >= end)
return_NULL;
- strcpy((char *) out, t->params);
+ strcpy(out, t->params);
out += len + 1;
/* align next block */
goto out;
do {
- names = (void *) names + next;
+ names = (struct dm_names *)((char *) names + next);
if (names->dev == dev) {
strncpy(buf, names->name, len);
r = 1;
struct target *t;
struct dm_target_msg *tmsg;
size_t len = sizeof(struct dm_ioctl);
- void *b, *e;
+ char *b, *e;
int count = 0;
for (t = dmt->head; t; t = t->next) {
dmi->target_count = count;
dmi->event_nr = dmt->event_nr;
- b = (void *) (dmi + 1);
- e = (void *) ((char *) dmi + len);
+ b = (char *) (dmi + 1);
+ e = (char *) dmi + len;
for (t = dmt->head; t; t = t->next)
if (!(b = _add_target(t, b, e))) {
goto out;
do {
- names = (void *) names + next;
+ names = (struct dm_names *)((char *) names + next);
if (!dm_task_set_name(dmt, names->name)) {
r = 0;
goto out;
/*
* Create a row of data for an object
*/
-static void * _report_get_field_data(struct dm_report *rh,
- struct field_properties *fp, void *object)
+static void *_report_get_field_data(struct dm_report *rh,
+ struct field_properties *fp, void *object)
{
- void *ret = fp->type->data_fn(object);
+ char *ret = fp->type->data_fn(object);
if (!ret)
return NULL;
- return ret + rh->fields[fp->field_num].offset;
+ return (void *)(ret + rh->fields[fp->field_num].offset);
}
int dm_report_object(struct dm_report *rh, void *object)
.SUFFIXES: .c .d .o .so .a .po .pot .mo .dylib
-CFLAGS += -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security -Wredundant-decls
+CFLAGS += -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security -Wredundant-decls -Wpointer-arith
-#CFLAGS += -W -Wconversion -Wpointer-arith -Wbad-function-cast -Wcast-qual
+#CFLAGS += -W -Wconversion -Wbad-function-cast -Wcast-qual
#CFLAGS += -pedantic -std=gnu99
#CFLAGS += -DDEBUG_CRC32