From 7405dd60380011d8fa46b64cd03fe86eb1616d7c Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Sat, 21 Sep 2013 12:03:57 -0500 Subject: [PATCH] dahdi: Fix placement of '/' in output of /proc/dahdi/x Fixes strings that look like: Span 1: TE2/0/1 "T2XXP (PCI) Card 0 Span 1" CCSHDB3//CRC4 RED To look like: Span 1: TE2/0/1 "T2XXP (PCI) Card 0 Span 1" CCS/HDB3/CRC4 RED Signed-off-by: Shaun Ruffell --- drivers/dahdi/dahdi-base.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c index 773b8a1..0893b97 100644 --- a/drivers/dahdi/dahdi-base.c +++ b/drivers/dahdi/dahdi-base.c @@ -787,6 +787,7 @@ ssize_t lineconfig_str(int lineconfig, char buf[], size_t size) int crc4_bit = 0; int len = 0; int bit; + bool written = false; for (bit = 4; bit <= 12; bit++) { int mask = (1 << bit); @@ -798,8 +799,10 @@ ssize_t lineconfig_str(int lineconfig, char buf[], size_t size) case DAHDI_CONFIG_AMI: case DAHDI_CONFIG_HDB3: framing_bit = bit; - len += snprintf(buf + len, size, "%s/", + len += snprintf(buf + len, size, "%s%s", + (written) ? "/" : "", dahdi_lineconfig_bit_name(bit)); + written = true; } } if (!coding_bit) { @@ -808,14 +811,18 @@ ssize_t lineconfig_str(int lineconfig, char buf[], size_t size) case DAHDI_CONFIG_D4: case DAHDI_CONFIG_CCS: coding_bit = bit; - len += snprintf(buf + len, size, "%s", + len += snprintf(buf + len, size, "%s%s", + (written) ? "/" : "", dahdi_lineconfig_bit_name(bit)); + written = true; } } if (!crc4_bit && mask == DAHDI_CONFIG_CRC4) { crc4_bit = bit; - len += snprintf(buf + len, size, "/%s", + len += snprintf(buf + len, size, "%s%s", + (written) ? "/" : "", dahdi_lineconfig_bit_name(bit)); + written = true; } } return len;