Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/crypto/external/bsd/netpgp/dist/src/lib simplify the code; t...
details: https://anonhg.NetBSD.org/src/rev/341e645675fb
branches: trunk
changeset: 768304:341e645675fb
user: christos <christos%NetBSD.org@localhost>
date: Sun Aug 14 11:19:51 2011 +0000
description:
simplify the code; this is what asprintf() is for, don't re-invent it.
diffstat:
crypto/external/bsd/netpgp/dist/src/lib/packet-show.c | 8 ++------
1 files changed, 2 insertions(+), 6 deletions(-)
diffs (36 lines):
diff -r 438ce1f1613d -r 341e645675fb crypto/external/bsd/netpgp/dist/src/lib/packet-show.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/packet-show.c Sun Aug 14 10:53:16 2011 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/packet-show.c Sun Aug 14 11:19:51 2011 +0000
@@ -60,7 +60,7 @@
#if defined(__NetBSD__)
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: packet-show.c,v 1.20 2010/11/15 08:50:32 agc Exp $");
+__RCSID("$NetBSD: packet-show.c,v 1.21 2011/08/14 11:19:51 christos Exp $");
#endif
#include <stdlib.h>
@@ -451,7 +451,6 @@
static unsigned
add_bitmap_entry(pgp_text_t *map, const char *str, uint8_t bit)
{
- const char *fmt_unknown = "Unknown bit(0x%x)";
if (str && !add_str(&map->known, str)) {
/*
@@ -468,14 +467,11 @@
* be replaced in the output by 2 chars of hex, so the length
* will be correct
*/
- unsigned len = (unsigned)(strlen(fmt_unknown) + 1);
char *newstr;
-
- if ((newstr = calloc(1, len)) == NULL) {
+ if (asprintf(&newstr, "Unknown bit(0x%x)", bit) == -1) {
(void) fprintf(stderr, "add_bitmap_entry: bad alloc\n");
return 0;
}
- (void) snprintf(newstr, len, fmt_unknown, bit);
if (!add_str(&map->unknown, newstr)) {
return 0;
}
Home |
Main Index |
Thread Index |
Old Index