gbranden pushed a commit to branch master
in repository groff.
commit 34485636758075c3119f0784644ed303f06a6674
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Mar 29 20:50:45 2026 -0500
[libgroff]: Fix `strsave()` code style nits.
* src/libs/libgroff/strsave.cpp (strsave): Arrange equality comparisons
to avoid inadvertent lvalue assignment. Favor C++ `static_cast<>`
operator over omnipotent C-style cast, except to explicitly discard
unused return value of function.
---
ChangeLog | 8 ++++++++
src/libs/libgroff/strsave.cpp | 10 +++++-----
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 13003eb17..4fb8d1a6f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2026-03-29 G. Branden Robinson <[email protected]>
+
+ * src/libs/libgroff/strsave.cpp: Fix code style nits. Arrange
+ equality comparisons to avoid inadvertent lvalue assignment.
+ Favor C++ `static_cast<>` operator over omnipotent C-style
+ cast, except to explicitly discard unused return value of
+ function.
+
2026-03-29 G. Branden Robinson <[email protected]>
* src/libs/libgroff/strsave.cpp: Improve header file
diff --git a/src/libs/libgroff/strsave.cpp b/src/libs/libgroff/strsave.cpp
index e8ac56104..2c55ff5cf 100644
--- a/src/libs/libgroff/strsave.cpp
+++ b/src/libs/libgroff/strsave.cpp
@@ -31,11 +31,11 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
char *strsave(const char *s)
{
- if (s == 0)
- return 0;
- char *p = (char*)malloc(strlen(s) + 1);
- if (p != 0)
- strcpy(p, s);
+ if (0 == s /* nullptr */)
+ return 0 /* nullptr */;
+ char *p = static_cast<char *>(malloc(strlen(s) + 1 /* '\0' */));
+ if (p != 0 /* nullptr */)
+ (void) strcpy(p, s);
return p;
}
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit