[Pkg-gnupg-commit] [gnupg2] 94/292: common: Avoid pointer arithmetic on string literals.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Mon Nov 21 06:31:29 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gnupg2.
commit 4aadc751f201f8f97c9c1f454e3a29803cce3edb
Author: Justus Winter <justus at g10code.com>
Date: Thu Oct 6 14:48:52 2016 +0200
common: Avoid pointer arithmetic on string literals.
* common/gettime.c (rfctimestamp): Use indexing instead.
* common/signal.c (got_fatal_signal): Likewise.
---
common/gettime.c | 6 +++---
common/signal.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/common/gettime.c b/common/gettime.c
index 9702bbc..9c63658 100644
--- a/common/gettime.c
+++ b/common/gettime.c
@@ -740,10 +740,10 @@ rfctimestamp (u32 stamp)
if (!tp)
return NULL;
return xtryasprintf ("%.3s, %02d %.3s %04d %02d:%02d:%02d +0000",
- ("SunMonTueWedThuFriSat" + (tp->tm_wday%7)*3),
+ &"SunMonTueWedThuFriSat"[(tp->tm_wday%7)*3],
tp->tm_mday,
- ("JanFebMarAprMayJunJulAugSepOctNovDec"
- + (tp->tm_mon%12)*3),
+ &"JanFebMarAprMayJunJulAugSepOctNovDec"
+ [(tp->tm_mon%12)*3],
tp->tm_year + 1900,
tp->tm_hour,
tp->tm_min,
diff --git a/common/signal.c b/common/signal.c
index b202f0f..9064adc 100644
--- a/common/signal.c
+++ b/common/signal.c
@@ -134,7 +134,7 @@ got_fatal_signal (int sig)
{
if (value >= i || ((any || i==1) && !(value/i)))
{
- (void)write (2, "0123456789"+(value/i), 1);
+ (void)write (2, &"0123456789"[value/i], 1);
if ((value/i))
any = 1;
value %= i;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list