MCPcopy Create free account
hub / github.com/apache/nuttx / find_devnum

Function find_devnum

net/netdev/netdev_register.c:134–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132 ****************************************************************************/
133
134static int find_devnum(FAR const char *devfmt)
135{
136 FAR struct net_driver_s *curr;
137 size_t fmt_size;
138 int result = 0;
139
140 fmt_size = strlen(devfmt);
141
142 /* Assumed that devfmt is xxx%d */
143
144 DEBUGASSERT(fmt_size > 2);
145 fmt_size -= 2;
146
147 /* Search the list of currently registered network devices */
148
149 for (curr = g_netdevices; curr; curr = curr->flink )
150 {
151 /* Does this device name match the format we were given? */
152
153 if (strncmp(curr->d_ifname, devfmt, fmt_size) == 0)
154 {
155 /* Yes.. increment the candidate device number */
156
157 result++;
158 }
159 }
160
161 /* Return this next device number for this format */
162
163 return result;
164}
165
166/****************************************************************************
167 * Name: get_ifindex

Callers 1

netdev_registerFunction · 0.85

Calls 2

strlenFunction · 0.50
strncmpFunction · 0.50

Tested by

no test coverage detected