From 84623f39dc9a78df85c18f3f46d8e4e6f872ecc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B6ppner?= Date: Wed, 7 Nov 2018 10:53:53 +0100 Subject: [PATCH] hyptop: Fix -Wrestrict warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure there are two different buffers passed to iconv() to get rid of the following GCC8 compile warning: helper.c: In function ‘ht_ebcdic_to_ascii’: helper.c:103:30: warning: passing argument 2 to restrict-qualified parameter aliases with argument 4 [-Wrestrict] iconv(l_iconv_ebcdic_ascii, &inout, &len, &inout, &len); ^~~~~~ ~~~~~~ helper.c:103:38: warning: passing argument 3 to restrict-qualified parameter aliases with argument 5 [-Wrestrict] iconv(l_iconv_ebcdic_ascii, &inout, &len, &inout, &len); ^~~~ ~~~~ Signed-off-by: Jan Höppner --- hyptop/dg_debugfs_lpar.c | 3 +-- hyptop/dg_debugfs_vm.c | 3 +-- hyptop/helper.c | 10 ++++++++-- hyptop/helper.h | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/hyptop/dg_debugfs_lpar.c b/hyptop/dg_debugfs_lpar.c index b63b9ec5..a675bf9d 100644 --- a/hyptop/dg_debugfs_lpar.c +++ b/hyptop/dg_debugfs_lpar.c @@ -55,8 +55,7 @@ struct l_x_sys_hdr { static inline void l_sys_hdr__sys_name(struct l_x_sys_hdr *hdr, char *name) { - memcpy(name, hdr->sys_name, LPAR_NAME_LEN); - ht_ebcdic_to_ascii(name, LPAR_NAME_LEN); + ht_ebcdic_to_ascii(hdr->sys_name, name, LPAR_NAME_LEN); name[LPAR_NAME_LEN] = 0; ht_strstrip(name); } diff --git a/hyptop/dg_debugfs_vm.c b/hyptop/dg_debugfs_vm.c index 669ddc9f..67235c3c 100644 --- a/hyptop/dg_debugfs_vm.c +++ b/hyptop/dg_debugfs_vm.c @@ -245,8 +245,7 @@ static void l_sd_sys_root_fill(struct sd_sys *sys) struct sd_sys *guest; guest_name[NAME_LEN] = 0; - memcpy(guest_name, data->guest_name, NAME_LEN); - ht_ebcdic_to_ascii(guest_name, NAME_LEN); + ht_ebcdic_to_ascii(data->guest_name, guest_name, NAME_LEN); ht_strstrip(guest_name); guest = sd_sys_get(sys, guest_name); diff --git a/hyptop/helper.c b/hyptop/helper.c index 9d5f7eda..7fb70ffe 100644 --- a/hyptop/helper.c +++ b/hyptop/helper.c @@ -98,9 +98,15 @@ void *ht_realloc(void *old_ptr, size_t size) /* * Convert EBCDIC string to ASCII */ -void ht_ebcdic_to_ascii(char *inout, size_t len) +void ht_ebcdic_to_ascii(char *in, char *out, size_t size) { - iconv(l_iconv_ebcdic_ascii, &inout, &len, &inout, &len); + size_t size_out = size; + size_t size_in = size; + size_t rc; + + rc = iconv(l_iconv_ebcdic_ascii, &in, &size_in, &out, &size_out); + if (rc == (size_t) -1) + ERR_EXIT_ERRNO("Code page translation EBCDIC-ASCII failed"); } /* diff --git a/hyptop/helper.h b/hyptop/helper.h index 2d304789..205b48f2 100644 --- a/hyptop/helper.h +++ b/hyptop/helper.h @@ -30,7 +30,7 @@ extern char *ht_strstrip(char *str); extern char *ht_strdup(const char *str); extern void ht_print_head(const char *sys); extern void ht_print_help_icon(void); -extern void ht_ebcdic_to_ascii(char *inout, size_t len); +extern void ht_ebcdic_to_ascii(char *in, char *out, size_t len); extern char *ht_mount_point_get(const char *fs_type); extern u64 ht_ext_tod_2_us(void *tod_ext); extern void ht_print_time(void);