WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit aea7a46

Browse files
committed
res_smdr_whozz: Decline to load if 'device' setting not set.
This is a rather niche module that almost nobody will use; therefore, comment this setting in the sample config and decline to load if it isn't specified. This way, even with the default sample configs installed, the module won't load unless the config has been modified by the user. This avoids a bunch of endless warnings in the console about failing to write to the serial port when it likely hasn't been configured for this use case.
1 parent 4a9d705 commit aea7a46

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

configs/samples/res_smdr_whozz.conf.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
;[general]
1212
;device=/dev/ttyS0 ; Device name of serial port to which WHOZZ Calling? unit is connected (9600/N/1)
13+
; This setting has no default and must be explicitly specified to use this module.
1314

1415
;[line-1]
1516
;line = 1 ; Line number as configured on WHOZZ Calling? unit.

res/res_smdr_whozz.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@
4848
<synopsis>WHOZZ Calling? SMDR</synopsis>
4949
<configFile name="res_smdr_whozz.conf">
5050
<configObject name="general">
51-
<configOption name="device" default="/dev/ttyS0">
51+
<configOption name="device">
5252
<synopsis>Serial device</synopsis>
5353
<description>
5454
<para>Serial device to use.</para>
5555
<para>Currently, only one serial device is supported. The units themselves allow them to be chained together
5656
so that only one serial connection to a PC is required.</para>
57+
<para>This setting has no default and must be explicitly specified.
58+
The default serial port on most systems is <literal>/dev/ttyS0</literal>.</para>
5759
</description>
5860
</configOption>
5961
</configObject>
@@ -149,7 +151,7 @@ static AST_RWLIST_HEAD_STATIC(lines, whozz_line);
149151
static pthread_t serial_thread = AST_PTHREADT_NULL;
150152
static int thread_running = 0;
151153

152-
static char serial_device[256] = "/dev/ttyS0"; /* Default serial port on a Linux system (especially if there's only one) */
154+
static char serial_device[256] = ""; /* No default setting, but default serial port on a Linux system is /dev/ttyS0 (especially if there's only one) */
153155
static int serial_fd = -1;
154156
static int unloading = 0;
155157

@@ -1177,6 +1179,12 @@ static int load_module(void)
11771179
return AST_MODULE_LOAD_DECLINE;
11781180
}
11791181

1182+
/* If no serial device explicitly specified, decline to load. */
1183+
if (ast_strlen_zero(serial_device)) {
1184+
unload_module();
1185+
return AST_MODULE_LOAD_DECLINE;
1186+
}
1187+
11801188
/* 9600/N/1 */
11811189
serial_fd = open(serial_device, O_RDWR | O_NONBLOCK | O_NOCTTY);
11821190
if (serial_fd < 0) {

0 commit comments

Comments
 (0)