[dahdi-commits] russell: linux/trunk r4664 - /linux/trunk/drivers/dahdi/dahdi-base.c
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Sat Aug 2 09:56:39 CDT 2008
Author: russell
Date: Sat Aug 2 09:56:38 2008
New Revision: 4664
URL: http://svn.digium.com/view/dahdi?view=rev&rev=4664
Log:
- align case with switch
- constify return of sigstr()
- rework implementation of fill_alarm_string to only use one call to snprintf()
and avoid more complicated string building logic
Modified:
linux/trunk/drivers/dahdi/dahdi-base.c
Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=4664&r1=4663&r2=4664
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Sat Aug 2 09:56:38 2008
@@ -469,76 +469,71 @@
}
#ifdef CONFIG_PROC_FS
-static char *sigstr(int sig)
+static const char *sigstr(int sig)
{
switch (sig) {
- case DAHDI_SIG_FXSLS:
- return "FXSLS";
- case DAHDI_SIG_FXSKS:
- return "FXSKS";
- case DAHDI_SIG_FXSGS:
- return "FXSGS";
- case DAHDI_SIG_FXOLS:
- return "FXOLS";
- case DAHDI_SIG_FXOKS:
- return "FXOKS";
- case DAHDI_SIG_FXOGS:
- return "FXOGS";
- case DAHDI_SIG_EM:
- return "E&M";
- case DAHDI_SIG_EM_E1:
- return "E&M-E1";
- case DAHDI_SIG_CLEAR:
- return "Clear";
- case DAHDI_SIG_HDLCRAW:
- return "HDLCRAW";
- case DAHDI_SIG_HDLCFCS:
- return "HDLCFCS";
- case DAHDI_SIG_HDLCNET:
- return "HDLCNET";
- case DAHDI_SIG_HARDHDLC:
- return "Hardware-assisted HDLC";
- case DAHDI_SIG_MTP2:
- return "MTP2";
- case DAHDI_SIG_SLAVE:
- return "Slave";
- case DAHDI_SIG_CAS:
- return "CAS";
- case DAHDI_SIG_DACS:
- return "DACS";
- case DAHDI_SIG_DACS_RBS:
- return "DACS+RBS";
- case DAHDI_SIG_SF:
- return "SF (ToneOnly)";
- case DAHDI_SIG_NONE:
- default:
- return "Unconfigured";
- }
-
-}
-
-static inline int fill_alarm_string(char *buf, int count, int alarms)
-{
- int len = 0;
-
- if (alarms > 0) {
- if (alarms & DAHDI_ALARM_BLUE)
- len += snprintf(buf + len, count - len, "BLUE ");
- if (alarms & DAHDI_ALARM_YELLOW)
- len += snprintf(buf + len, count - len, "YELLOW ");
- if (alarms & DAHDI_ALARM_RED)
- len += snprintf(buf + len, count - len, "RED ");
- if (alarms & DAHDI_ALARM_LOOPBACK)
- len += snprintf(buf + len, count - len, "LOOP ");
- if (alarms & DAHDI_ALARM_RECOVER)
- len += snprintf(buf + len, count - len, "RECOVERING ");
- if (alarms & DAHDI_ALARM_NOTOPEN)
- len += snprintf(buf + len, count - len, "NOTOPEN ");
- }
- if(len > 0) {
- len--;
- buf[len] = '\0'; /* strip last space */
- }
+ case DAHDI_SIG_FXSLS:
+ return "FXSLS";
+ case DAHDI_SIG_FXSKS:
+ return "FXSKS";
+ case DAHDI_SIG_FXSGS:
+ return "FXSGS";
+ case DAHDI_SIG_FXOLS:
+ return "FXOLS";
+ case DAHDI_SIG_FXOKS:
+ return "FXOKS";
+ case DAHDI_SIG_FXOGS:
+ return "FXOGS";
+ case DAHDI_SIG_EM:
+ return "E&M";
+ case DAHDI_SIG_EM_E1:
+ return "E&M-E1";
+ case DAHDI_SIG_CLEAR:
+ return "Clear";
+ case DAHDI_SIG_HDLCRAW:
+ return "HDLCRAW";
+ case DAHDI_SIG_HDLCFCS:
+ return "HDLCFCS";
+ case DAHDI_SIG_HDLCNET:
+ return "HDLCNET";
+ case DAHDI_SIG_HARDHDLC:
+ return "Hardware-assisted HDLC";
+ case DAHDI_SIG_MTP2:
+ return "MTP2";
+ case DAHDI_SIG_SLAVE:
+ return "Slave";
+ case DAHDI_SIG_CAS:
+ return "CAS";
+ case DAHDI_SIG_DACS:
+ return "DACS";
+ case DAHDI_SIG_DACS_RBS:
+ return "DACS+RBS";
+ case DAHDI_SIG_SF:
+ return "SF (ToneOnly)";
+ case DAHDI_SIG_NONE:
+ default:
+ return "Unconfigured";
+ }
+}
+
+static int fill_alarm_string(char *buf, int count, int alarms)
+{
+ int len;
+
+ if (alarms <= 0)
+ return 0;
+
+ len = snprintf(buf, count, "%s%s%s%s%s%s",
+ (alarms & DAHDI_ALARM_BLUE) ? "BLUE " : "",
+ (alarms & DAHDI_ALARM_YELLOW) ? "YELLOW " : "",
+ (alarms & DAHDI_ALARM_RED) ? "RED " : "",
+ (alarms & DAHDI_ALARM_LOOPBACK) ? "LOOP " : "",
+ (alarms & DAHDI_ALARM_RECOVER) ? "RECOVERING " : "",
+ (alarms & DAHDI_ALARM_NOTOPEN) ? "NOTOPEN " : "");
+
+ if (len)
+ buf[--len] = '\0'; /* strip last space */
+
return len;
}
More information about the dahdi-commits
mailing list