[systemd-commits] 4 commits - src/journal src/libsystemd-terminal src/libudev src/resolve-host src/shared
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Sun Aug 3 20:54:21 PDT 2014
src/journal/compress.c | 43 ++++++++++++++++-----------------
src/journal/compress.h | 24 +++++++++---------
src/journal/journal-file.c | 9 +++---
src/journal/journal-file.h | 2 -
src/journal/journal-verify.c | 2 -
src/journal/journald-native.c | 2 -
src/journal/sd-journal.c | 4 +--
src/journal/test-compress-benchmark.c | 10 +++----
src/journal/test-compress.c | 19 ++++++--------
src/libsystemd-terminal/term-wcwidth.c | 4 +--
src/libudev/libudev-hwdb.c | 2 -
src/resolve-host/resolve-host.c | 2 -
src/shared/util.h | 2 -
13 files changed, 63 insertions(+), 62 deletions(-)
New commits:
commit 61b385c616633f12339411b68be29501fdb5fa18
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sun Aug 3 23:40:00 2014 -0400
terminal: avoid warning about signed-unsigned comparison
diff --git a/src/libsystemd-terminal/term-wcwidth.c b/src/libsystemd-terminal/term-wcwidth.c
index 443161c..df20a40 100644
--- a/src/libsystemd-terminal/term-wcwidth.c
+++ b/src/libsystemd-terminal/term-wcwidth.c
@@ -66,8 +66,8 @@
#include "term-internal.h"
struct interval {
- int first;
- int last;
+ wchar_t first;
+ wchar_t last;
};
/* auxiliary function for binary search in interval table */
commit 590baf91f3fc9f0edd7986c66da00be10e48a25d
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sun Aug 3 23:41:45 2014 -0400
resolve-host: fix missed search&replace
diff --git a/src/resolve-host/resolve-host.c b/src/resolve-host/resolve-host.c
index 4b46cdf..43c8a22 100644
--- a/src/resolve-host/resolve-host.c
+++ b/src/resolve-host/resolve-host.c
@@ -486,7 +486,7 @@ static int parse_argv(int argc, char *argv[]) {
arg_type = dns_type_from_string(optarg);
if (arg_type < 0) {
log_error("Failed to parse RR record type %s", optarg);
- return r;
+ return arg_type;
}
assert(arg_type > 0 && (uint16_t) arg_type == arg_type);
commit fa1c4b518ec7d8ec2d647213ee651cde4d6c9d7e
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sun Aug 3 22:50:00 2014 -0400
Fix misuse of uint64_t as size_t
They have different size on 32 bit, so they are really not interchangable.
diff --git a/src/journal/compress.c b/src/journal/compress.c
index ee18bc8..52a4c10 100644
--- a/src/journal/compress.c
+++ b/src/journal/compress.c
@@ -47,7 +47,7 @@ static const char* const object_compressed_table[_OBJECT_COMPRESSED_MAX] = {
DEFINE_STRING_TABLE_LOOKUP(object_compressed, int);
-int compress_blob_xz(const void *src, uint64_t src_size, void *dst, uint64_t *dst_size) {
+int compress_blob_xz(const void *src, uint64_t src_size, void *dst, size_t *dst_size) {
#ifdef HAVE_XZ
static const lzma_options_lzma opt = {
1u << 20u, NULL, 0, LZMA_LC_DEFAULT, LZMA_LP_DEFAULT,
@@ -82,7 +82,7 @@ int compress_blob_xz(const void *src, uint64_t src_size, void *dst, uint64_t *ds
#endif
}
-int compress_blob_lz4(const void *src, uint64_t src_size, void *dst, uint64_t *dst_size) {
+int compress_blob_lz4(const void *src, uint64_t src_size, void *dst, size_t *dst_size) {
#ifdef HAVE_LZ4
int r;
@@ -112,12 +112,12 @@ int compress_blob_lz4(const void *src, uint64_t src_size, void *dst, uint64_t *d
int decompress_blob_xz(const void *src, uint64_t src_size,
- void **dst, uint64_t *dst_alloc_size, uint64_t* dst_size, uint64_t dst_max) {
+ void **dst, size_t *dst_alloc_size, size_t* dst_size, size_t dst_max) {
#ifdef HAVE_XZ
_cleanup_(lzma_end) lzma_stream s = LZMA_STREAM_INIT;
lzma_ret ret;
- uint64_t space;
+ size_t space;
assert(src);
assert(src_size > 0);
@@ -130,7 +130,7 @@ int decompress_blob_xz(const void *src, uint64_t src_size,
if (ret != LZMA_OK)
return -ENOMEM;
- space = MIN(src_size * 2, dst_max ?: (uint64_t) -1);
+ space = MIN(src_size * 2, dst_max ?: (size_t) -1);
if (!greedy_realloc(dst, dst_alloc_size, space, 1))
return -ENOMEM;
@@ -141,7 +141,7 @@ int decompress_blob_xz(const void *src, uint64_t src_size,
s.avail_out = space;
for (;;) {
- uint64_t used;
+ size_t used;
ret = lzma_code(&s, LZMA_FINISH);
@@ -156,7 +156,7 @@ int decompress_blob_xz(const void *src, uint64_t src_size,
return -ENOBUFS;
used = space - s.avail_out;
- space = MIN(2 * space, dst_max ?: (uint64_t) -1);
+ space = MIN(2 * space, dst_max ?: (size_t) -1);
if (!greedy_realloc(dst, dst_alloc_size, space, 1))
return -ENOMEM;
@@ -172,12 +172,11 @@ int decompress_blob_xz(const void *src, uint64_t src_size,
}
int decompress_blob_lz4(const void *src, uint64_t src_size,
- void **dst, uint64_t *dst_alloc_size, uint64_t* dst_size, uint64_t dst_max) {
+ void **dst, size_t *dst_alloc_size, size_t* dst_size, size_t dst_max) {
#ifdef HAVE_LZ4
char* out;
- uint64_t size;
- int r;
+ int r, size; /* LZ4 uses int for size */
assert(src);
assert(src_size > 0);
@@ -190,7 +189,9 @@ int decompress_blob_lz4(const void *src, uint64_t src_size,
return -EBADMSG;
size = le64toh( *(le64_t*)src );
- if (size > *dst_alloc_size) {
+ if (size < 0 || (le64_t) size != *(le64_t*)src)
+ return -EFBIG;
+ if ((size_t) size > *dst_alloc_size) {
out = realloc(*dst, size);
if (!out)
return -ENOMEM;
@@ -200,7 +201,7 @@ int decompress_blob_lz4(const void *src, uint64_t src_size,
out = *dst;
r = LZ4_decompress_safe(src + 8, out, src_size - 8, size);
- if (r < 0 || (uint64_t) r != size)
+ if (r < 0 || r != size)
return -EBADMSG;
*dst_size = size;
@@ -212,7 +213,7 @@ int decompress_blob_lz4(const void *src, uint64_t src_size,
int decompress_blob(int compression,
const void *src, uint64_t src_size,
- void **dst, uint64_t *dst_alloc_size, uint64_t* dst_size, uint64_t dst_max) {
+ void **dst, size_t *dst_alloc_size, size_t* dst_size, size_t dst_max) {
if (compression == OBJECT_COMPRESSED_XZ)
return decompress_blob_xz(src, src_size,
dst, dst_alloc_size, dst_size, dst_max);
@@ -225,8 +226,8 @@ int decompress_blob(int compression,
int decompress_startswith_xz(const void *src, uint64_t src_size,
- void **buffer, uint64_t *buffer_size,
- const void *prefix, uint64_t prefix_len,
+ void **buffer, size_t *buffer_size,
+ const void *prefix, size_t prefix_len,
uint8_t extra) {
#ifdef HAVE_XZ
@@ -284,8 +285,8 @@ int decompress_startswith_xz(const void *src, uint64_t src_size,
}
int decompress_startswith_lz4(const void *src, uint64_t src_size,
- void **buffer, uint64_t *buffer_size,
- const void *prefix, uint64_t prefix_len,
+ void **buffer, size_t *buffer_size,
+ const void *prefix, size_t prefix_len,
uint8_t extra) {
#ifdef HAVE_LZ4
/* Checks whether the decompressed blob starts with the
@@ -325,8 +326,8 @@ int decompress_startswith_lz4(const void *src, uint64_t src_size,
int decompress_startswith(int compression,
const void *src, uint64_t src_size,
- void **buffer, uint64_t *buffer_size,
- const void *prefix, uint64_t prefix_len,
+ void **buffer, size_t *buffer_size,
+ const void *prefix, size_t prefix_len,
uint8_t extra) {
if (compression == OBJECT_COMPRESSED_XZ)
return decompress_startswith_xz(src, src_size,
@@ -407,7 +408,7 @@ int compress_stream_xz(int fdf, int fdt, off_t max_bytes) {
return errno ? -errno : -EIO;
if (ret == LZMA_STREAM_END) {
- log_debug("XZ compression finished (%zu -> %zu bytes, %.1f%%)",
+ log_debug("XZ compression finished (%"PRIu64" -> %"PRIu64" bytes, %.1f%%)",
s.total_in, s.total_out,
(double) s.total_out / s.total_in * 100);
@@ -566,7 +567,7 @@ int decompress_stream_xz(int fdf, int fdt, off_t max_bytes) {
return errno ? -errno : -EIO;
if (ret == LZMA_STREAM_END) {
- log_debug("XZ decompression finished (%zu -> %zu bytes, %.1f%%)",
+ log_debug("XZ decompression finished (%"PRIu64" -> %"PRIu64" bytes, %.1f%%)",
s.total_in, s.total_out,
(double) s.total_out / s.total_in * 100);
diff --git a/src/journal/compress.h b/src/journal/compress.h
index 92621ba..136dda6 100644
--- a/src/journal/compress.h
+++ b/src/journal/compress.h
@@ -30,10 +30,10 @@
const char* object_compressed_to_string(int compression);
int object_compressed_from_string(const char *compression);
-int compress_blob_xz(const void *src, uint64_t src_size, void *dst, uint64_t *dst_size);
-int compress_blob_lz4(const void *src, uint64_t src_size, void *dst, uint64_t *dst_size);
+int compress_blob_xz(const void *src, uint64_t src_size, void *dst, size_t *dst_size);
+int compress_blob_lz4(const void *src, uint64_t src_size, void *dst, size_t *dst_size);
-static inline int compress_blob(const void *src, uint64_t src_size, void *dst, uint64_t *dst_size) {
+static inline int compress_blob(const void *src, uint64_t src_size, void *dst, size_t *dst_size) {
int r;
#ifdef HAVE_LZ4
r = compress_blob_lz4(src, src_size, dst, dst_size);
@@ -48,25 +48,25 @@ static inline int compress_blob(const void *src, uint64_t src_size, void *dst, u
}
int decompress_blob_xz(const void *src, uint64_t src_size,
- void **dst, uint64_t *dst_alloc_size, uint64_t* dst_size, uint64_t dst_max);
+ void **dst, size_t *dst_alloc_size, size_t* dst_size, size_t dst_max);
int decompress_blob_lz4(const void *src, uint64_t src_size,
- void **dst, uint64_t *dst_alloc_size, uint64_t* dst_size, uint64_t dst_max);
+ void **dst, size_t *dst_alloc_size, size_t* dst_size, size_t dst_max);
int decompress_blob(int compression,
const void *src, uint64_t src_size,
- void **dst, uint64_t *dst_alloc_size, uint64_t* dst_size, uint64_t dst_max);
+ void **dst, size_t *dst_alloc_size, size_t* dst_size, size_t dst_max);
int decompress_startswith_xz(const void *src, uint64_t src_size,
- void **buffer, uint64_t *buffer_size,
- const void *prefix, uint64_t prefix_len,
+ void **buffer, size_t *buffer_size,
+ const void *prefix, size_t prefix_len,
uint8_t extra);
int decompress_startswith_lz4(const void *src, uint64_t src_size,
- void **buffer, uint64_t *buffer_size,
- const void *prefix, uint64_t prefix_len,
+ void **buffer, size_t *buffer_size,
+ const void *prefix, size_t prefix_len,
uint8_t extra);
int decompress_startswith(int compression,
const void *src, uint64_t src_size,
- void **buffer, uint64_t *buffer_size,
- const void *prefix, uint64_t prefix_len,
+ void **buffer, size_t *buffer_size,
+ const void *prefix, size_t prefix_len,
uint8_t extra);
int compress_stream_xz(int fdf, int fdt, off_t max_bytes);
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 6679ea4..986e94d 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -814,7 +814,8 @@ int journal_file_find_data_object_with_hash(
if (o->object.flags & OBJECT_COMPRESSION_MASK) {
#if defined(HAVE_XZ) || defined(HAVE_LZ4)
- uint64_t l, rsize;
+ uint64_t l;
+ size_t rsize;
l = le64toh(o->object.size);
if (l <= offsetof(Object, data.payload))
@@ -979,7 +980,7 @@ static int journal_file_append_data(
#if defined(HAVE_XZ) || defined(HAVE_LZ4)
if (f->compress_xz &&
size >= COMPRESSION_SIZE_THRESHOLD) {
- uint64_t rsize;
+ size_t rsize;
compression = compress_blob(data, size, o->data.payload, &rsize);
@@ -987,7 +988,7 @@ static int journal_file_append_data(
o->object.size = htole64(offsetof(Object, data.payload) + rsize);
o->object.flags |= compression;
- log_debug("Compressed data object %"PRIu64" -> %"PRIu64" using %s",
+ log_debug("Compressed data object %"PRIu64" -> %zu using %s",
size, rsize, object_compressed_to_string(compression));
}
}
@@ -2770,7 +2771,7 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6
if (o->object.flags & OBJECT_COMPRESSION_MASK) {
#if defined(HAVE_XZ) || defined(HAVE_LZ4)
- uint64_t rsize;
+ size_t rsize;
r = decompress_blob(o->object.flags & OBJECT_COMPRESSION_MASK,
o->data.payload, l, &from->compress_buffer, &from->compress_buffer_size, &rsize, 0);
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index 6703b93..3d41682 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -80,7 +80,7 @@ typedef struct JournalFile {
#ifdef HAVE_XZ
void *compress_buffer;
- uint64_t compress_buffer_size;
+ size_t compress_buffer_size;
#endif
#ifdef HAVE_GCRYPT
diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c
index 333757b..6c8ca8c 100644
--- a/src/journal/journal-verify.c
+++ b/src/journal/journal-verify.c
@@ -142,7 +142,7 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
compression = o->object.flags & OBJECT_COMPRESSION_MASK;
if (compression) {
_cleanup_free_ void *b = NULL;
- uint64_t alloc = 0, b_size;
+ size_t alloc = 0, b_size;
r = decompress_blob(compression,
o->data.payload,
diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
index d73280c..6bc5df7 100644
--- a/src/journal/journald-native.c
+++ b/src/journal/journald-native.c
@@ -223,7 +223,7 @@ void server_process_native_message(
l = le64toh(l_le);
if (l > DATA_SIZE_MAX) {
- log_debug("Received binary data block of %zu bytes is too large, ignoring.", l);
+ log_debug("Received binary data block of %"PRIu64" bytes is too large, ignoring.", l);
break;
}
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 01c91e4..b9ec902 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -2004,7 +2004,7 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **
&f->compress_buffer, &f->compress_buffer_size,
field, field_length, '=')) {
- uint64_t rsize;
+ size_t rsize;
r = decompress_blob(compression,
o->data.payload, l,
@@ -2059,7 +2059,7 @@ static int return_data(sd_journal *j, JournalFile *f, Object *o, const void **da
compression = o->object.flags & OBJECT_COMPRESSION_MASK;
if (compression) {
#if defined(HAVE_XZ) || defined(HAVE_LZ4)
- uint64_t rsize;
+ size_t rsize;
int r;
r = decompress_blob(compression,
diff --git a/src/journal/test-compress-benchmark.c b/src/journal/test-compress-benchmark.c
index 0141df4..8975e29 100644
--- a/src/journal/test-compress-benchmark.c
+++ b/src/journal/test-compress-benchmark.c
@@ -21,9 +21,9 @@
#include "util.h"
#include "macro.h"
-typedef int (compress_t)(const void *src, uint64_t src_size, void *dst, uint64_t *dst_size);
+typedef int (compress_t)(const void *src, uint64_t src_size, void *dst, size_t *dst_size);
typedef int (decompress_t)(const void *src, uint64_t src_size,
- void **dst, uint64_t *dst_alloc_size, uint64_t* dst_size, uint64_t dst_max);
+ void **dst, size_t *dst_alloc_size, size_t* dst_size, size_t dst_max);
#define MAX_SIZE (1024*1024LU)
@@ -47,7 +47,7 @@ static void test_compress_decompress(const char* label,
_cleanup_free_ char *text, *buf;
_cleanup_free_ void *buf2 = NULL;
- uint64_t buf2_allocated = 0;
+ size_t buf2_allocated = 0;
size_t skipped = 0, compressed = 0, total = 0;
text = make_buf(MAX_SIZE);
@@ -57,7 +57,7 @@ static void test_compress_decompress(const char* label,
n = now(CLOCK_MONOTONIC);
for (size_t i = 1; i <= MAX_SIZE; i += (i < 2048 ? 1 : 217)) {
- uint64_t j = 0, k = 0;
+ size_t j = 0, k = 0;
int r;
r = compress(text, i, buf, &j);
@@ -72,7 +72,7 @@ static void test_compress_decompress(const char* label,
assert(j > 0);
if (j >= i)
- log_error("%s \"compressed\" %zu -> %" PRIu64, label, i, j);
+ log_error("%s \"compressed\" %zu -> %zu", label, i, j);
r = decompress(buf, j, &buf2, &buf2_allocated, &k, 0);
assert(r == 0);
diff --git a/src/journal/test-compress.c b/src/journal/test-compress.c
index 4c0a9a0..f5f5f8d 100644
--- a/src/journal/test-compress.c
+++ b/src/journal/test-compress.c
@@ -34,14 +34,13 @@
#endif
typedef int (compress_blob_t)(const void *src, uint64_t src_size,
- void *dst, uint64_t *dst_size);
+ void *dst, size_t *dst_size);
typedef int (decompress_blob_t)(const void *src, uint64_t src_size,
- void **dst, uint64_t *dst_alloc_size,
- uint64_t* dst_size, uint64_t dst_max);
-
+ void **dst, size_t *dst_alloc_size,
+ size_t* dst_size, size_t dst_max);
typedef int (decompress_sw_t)(const void *src, uint64_t src_size,
- void **buffer, uint64_t *buffer_size,
- const void *prefix, uint64_t prefix_len,
+ void **buffer, size_t *buffer_size,
+ const void *prefix, size_t prefix_len,
uint8_t extra);
typedef int (compress_stream_t)(int fdf, int fdt, off_t max_bytes);
@@ -53,8 +52,8 @@ static void test_compress_decompress(int compression,
char text[] = "foofoofoofoo AAAA aaaaaaaaa ghost busters barbarbar FFF"
"foofoofoofoo AAAA aaaaaaaaa ghost busters barbarbar FFF";
char compressed[512];
- uint64_t csize = 512;
- uint64_t usize = 0;
+ size_t csize = 512;
+ size_t usize = 0;
_cleanup_free_ char *decompressed = NULL;
int r;
@@ -92,8 +91,8 @@ static void test_decompress_startswith(int compression,
char text[] = "foofoofoofoo AAAA aaaaaaaaa ghost busters barbarbar FFF"
"foofoofoofoo AAAA aaaaaaaaa ghost busters barbarbar FFF";
char compressed[512];
- uint64_t csize = 512;
- uint64_t usize = 0;
+ size_t csize = 512;
+ size_t usize = 0;
_cleanup_free_ char *decompressed = NULL;
log_info("/* testing decompress_startswith with %s */",
diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c
index e0d4d7c..8fb7240 100644
--- a/src/libudev/libudev-hwdb.c
+++ b/src/libudev/libudev-hwdb.c
@@ -305,7 +305,7 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
udev_dbg(udev, "=== trie on-disk ===\n");
udev_dbg(udev, "tool version: %"PRIu64, le64toh(hwdb->head->tool_version));
- udev_dbg(udev, "file size: %8zu bytes\n", hwdb->st.st_size);
+ udev_dbg(udev, "file size: %8"PRIu64" bytes\n", hwdb->st.st_size);
udev_dbg(udev, "header size %8"PRIu64" bytes\n", le64toh(hwdb->head->header_size));
udev_dbg(udev, "strings %8"PRIu64" bytes\n", le64toh(hwdb->head->strings_len));
udev_dbg(udev, "nodes %8"PRIu64" bytes\n", le64toh(hwdb->head->nodes_len));
commit 1f2b7175cf84bdbef6ee6917224658ba2adf43bf
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sun Aug 3 22:11:34 2014 -0400
util.h: fix typo
diff --git a/src/shared/util.h b/src/shared/util.h
index 3e89aaf..8231cf2 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -69,7 +69,7 @@
#if SIZEOF_TIME_T == 8
# define PRI_TIME PRIu64
-#elif SIZEOF_GID_T == 4
+#elif SIZEOF_TIME_T == 4
# define PRI_TIME PRIu32
#else
# error Unknown time_t size
More information about the systemd-commits
mailing list