[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 10/10: [gxditview]: Fix code sytle nits.
From: |
G. Branden Robinson |
Subject: |
[groff] 10/10: [gxditview]: Fix code sytle nits. |
Date: |
Thu, 17 Oct 2024 20:39:44 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 30e90e55ca1c21ae0cb16dda25d7fbfbcb6b5a0e
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Thu Oct 17 17:40:44 2024 -0500
[gxditview]: Fix code sytle nits.
* src/devices/xditview/xditview.c (NewFile): Fix code style nits.
Promote repeated expression to temporary variable. `sizeof` is an
operator, not a function, so don't parenthesize its parameter when
it's an lvalue (as opposed to a type name).
---
ChangeLog | 7 +++++++
src/devices/xditview/xditview.c | 5 +++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c88aea9c7..833617c1c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-10-17 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/devices/xditview/xditview.c (NewFile): Fix code style
+ nits. Promote repeated expression to temporary variable.
+ `sizeof` is an operator, not a function, so don't parenthesize
+ its parameter when it's an lvalue (as opposed to a type name).
+
2024-08-12 Lukas Javorsky <ljavorsk@redhat.com>
* src/devices/xditview/xditview.c (NewFile): Populate
diff --git a/src/devices/xditview/xditview.c b/src/devices/xditview/xditview.c
index d8bd8cabd..ff21fb6e7 100644
--- a/src/devices/xditview/xditview.c
+++ b/src/devices/xditview/xditview.c
@@ -367,8 +367,9 @@ NewFile (const char *name)
}
hadFile = 1;
SelectPageNumber ("1");
- strncpy(current_file_name, name, sizeof(current_file_name) - 1);
- current_file_name[sizeof(current_file_name) - 1] = '\0'; // Ensure
null-termination
+ size_t len = (sizeof current_file_name) - 1;
+ strncpy(current_file_name, name, len);
+ current_file_name[len] = '\0';
current_file = new_file;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 10/10: [gxditview]: Fix code sytle nits.,
G. Branden Robinson <=