Skip to content

Commit 92ee7da

Browse files
committed
Remove remaining no-op strrchr() calls.
Apparently, its intended purpose indeed is to skip an optional "/dev/" before the capture device name, but only in open_dlpi_device(), which seems to handle the return value correctly. The instances in other modules are no-op side effects of commit 2426611. Eliminate the local variable as well where it makes sense.
1 parent e525e13 commit 92ee7da

File tree

5 files changed

+5
-20
lines changed

5 files changed

+5
-20
lines changed

pcap-bt-linux.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,7 @@ bt_create(const char *device, char *ebuf, int *is_ours)
154154
pcap_t *p;
155155

156156
/* Does this look like a Bluetooth device? */
157-
cp = strrchr(device, '/');
158-
if (cp == NULL)
159-
cp = device;
157+
cp = device;
160158
/* Does it begin with BT_IFACE? */
161159
if (strncmp(cp, BT_IFACE, sizeof BT_IFACE - 1) != 0) {
162160
/* Nope, doesn't begin with BT_IFACE */

pcap-bt-monitor-linux.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,8 @@ pcap_t *
258258
bt_monitor_create(const char *device, char *ebuf, int *is_ours)
259259
{
260260
pcap_t *p;
261-
const char *cp;
262261

263-
cp = strrchr(device, '/');
264-
if (cp == NULL)
265-
cp = device;
266-
267-
if (strcmp(cp, INTERFACE_NAME) != 0) {
262+
if (strcmp(device, INTERFACE_NAME) != 0) {
268263
*is_ours = 0;
269264
return NULL;
270265
}

pcap-netfilter-linux.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,7 @@ netfilter_create(const char *device, char *ebuf, int *is_ours)
729729
pcap_t *p;
730730

731731
/* Does this look like an netfilter device? */
732-
cp = strrchr(device, '/');
733-
if (cp == NULL)
734-
cp = device;
732+
cp = device;
735733

736734
/* Does it begin with NFLOG_IFACE or NFQUEUE_IFACE? */
737735
if (strncmp(cp, NFLOG_IFACE, sizeof NFLOG_IFACE - 1) == 0)

pcap-septel.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,10 @@ static pcap_t *septel_activate(pcap_t* handle) {
215215
}
216216

217217
pcap_t *septel_create(const char *device, char *ebuf, int *is_ours) {
218-
const char *cp;
219218
pcap_t *p;
220219

221220
/* Does this look like the Septel device? */
222-
cp = strrchr(device, '/');
223-
if (cp == NULL)
224-
cp = device;
225-
if (strcmp(cp, "septel") != 0) {
221+
if (strcmp(device, "septel") != 0) {
226222
/* Nope, it's not "septel" */
227223
*is_ours = 0;
228224
return NULL;

pcap-usb-linux.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,7 @@ usb_create(const char *device, char *ebuf, int *is_ours)
419419
pcap_t *p;
420420

421421
/* Does this look like a USB monitoring device? */
422-
cp = strrchr(device, '/');
423-
if (cp == NULL)
424-
cp = device;
422+
cp = device;
425423
/* Does it begin with USB_IFACE? */
426424
if (strncmp(cp, USB_IFACE, sizeof USB_IFACE - 1) != 0) {
427425
/* Nope, doesn't begin with USB_IFACE */

0 commit comments

Comments
 (0)