It's unlikely that we'll try 2^31-1 devices without success and overflow
to 2^31, but this is cleaner (and BPF devices won't have negative device
numbers).
That means the buffer for the device name doesn't need to leave room for
the minus sign; that's what the compiler was warning about.
(cherry picked from commit
7610a61d72c818067a1e51f150b81ee7d489a577)
{
int fd = -1;
static const char cloning_device[] = "/dev/bpf";
- int n = 0;
- char device[sizeof "/dev/bpf00000000000"];
+ u_int n = 0;
+ char device[sizeof "/dev/bpf0000000000"];
static int no_cloning_bpf = 0;
#ifdef _AIX
* that isn't in use.
*/
do {
- (void)snprintf(device, sizeof(device), "/dev/bpf%d", n++);
+ (void)snprintf(device, sizeof(device), "/dev/bpf%u", n++);
/*
* Initially try a read/write open (to allow the inject
* method to work). If that fails due to permission