[ghex] Fix further format string warnings
- From: Logan Rathbone <larathbone src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ghex] Fix further format string warnings
- Date: Mon, 10 Jan 2022 22:19:40 +0000 (UTC)
commit eb1900a579d6336e77942ae3d1b5804aceaf17ac
Author: Logan Rathbone <poprocks gmail com>
Date: Mon Jan 10 17:18:19 2022 -0500
Fix further format string warnings
See !24
src/gtkhex.c | 6 +++++-
src/hex-buffer-mmap.c | 10 +++++++---
2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/gtkhex.c b/src/gtkhex.c
index 48a0e39..c34b57f 100644
--- a/src/gtkhex.c
+++ b/src/gtkhex.c
@@ -1132,10 +1132,14 @@ render_offsets (HexWidget *self,
snprintf (fmt, BUFLEN-1, "%%0%dlX", off_cpl);
hex_widget_layout_set_offset_cpl (HEX_WIDGET_LAYOUT(self->layout_manager), off_cpl);
- for (int i = min_lines; i <= max_lines; i++) {
+ for (int i = min_lines; i <= max_lines; i++)
+ {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
/* generate offset string and place in temporary buffer */
sprintf(off_str, fmt,
(self->top_line + i) * self->cpl + STARTING_OFFSET);
+#pragma GCC diagnostic pop
/* build pango layout for offset line; draw line with gtk. */
pango_layout_set_text (self->olayout, off_str, off_cpl);
diff --git a/src/hex-buffer-mmap.c b/src/hex-buffer-mmap.c
index bb49d5d..5bd07f5 100644
--- a/src/hex-buffer-mmap.c
+++ b/src/hex-buffer-mmap.c
@@ -171,14 +171,18 @@ set_error (HexBufferMmap *self, const char *blurb)
* (eg, 'No such file or directory').
*/
message = g_strdup_printf (_("%s: %s"), blurb, g_strerror (errno));
- g_debug ("%s: %s", __func__, message);
}
+ else
+ {
+ message = g_strdup (blurb);
+ }
+ g_debug ("%s: %s", __func__, message);
g_set_error (&self->error,
HEX_BUFFER_MMAP_ERROR,
errno,
- message ? message : blurb,
- g_strerror (errno));
+ "%s",
+ message);
if (errno)
self->last_errno = errno;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]