gbranden pushed a commit to branch master
in repository groff.
commit 30e90e55ca1c21ae0cb16dda25d7fbfbcb6b5a0e
Author: G. Branden Robinson <[email protected]>
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 <[email protected]>
+
+ * 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 <[email protected]>
* 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;
}
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit