#include <stdio.h> #include <errno.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> struct socket_testcase { int domain; int type; int protocol; /* 0 = valid file descriptor * -foo = error foo */ int expect; /* If non-zero, accept EAFNOSUPPORT to handle the case * of the protocol not being configured into the kernel. */ int nosupport_ok; }; static struct socket_testcase tests[] = { { AF_MAX, 0, 0, -EAFNOSUPPORT, 0 }, { AF_INET, SOCK_STREAM, IPPROTO_TCP, 0, 1 }, { AF_INET, SOCK_DGRAM, IPPROTO_TCP, -EPROTONOSUPPORT, 1 }, { AF_INET, SOCK_DGRAM, IPPROTO_UDP, 0, 1 }, { AF_INET, SOCK_STREAM, IPPROTO_UDP, -EPROTONOSUPPORT, 1 }, }; #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) #define ERR_STRING_SZ 64 static int run_tests(void) { char err_string1[ERR_STRING_SZ]; char err_string2[ERR_STRING_SZ]; int i, err; err = 0; for (i = 0; i < ARRAY_SIZE(tests); i++) { struct socket_testcase *s = &tests[i]; int fd; fd = socket(s->domain, s->type, s->protocol); if (fd < 0) { if (s->nosupport_ok && errno == EAFNOSUPPORT) continue; if (s->expect < 0 && errno == -s->expect) continue; strerror_r(-s->expect, err_string1, ERR_STRING_SZ); strerror_r(errno, err_string2, ERR_STRING_SZ); fprintf(stderr, "socket(%d, %d, %d) expected " "err (%s) got (%s)\n", s->domain, s->type, s->protocol, err_string1, err_string2); err = -1; break; } else { close(fd); if (s->expect < 0) { strerror_r(errno, err_string1, ERR_STRING_SZ); fprintf(stderr, "socket(%d, %d, %d) expected " "success got err (%s)\n", s->domain, s->type, s->protocol, err_string1); err = -1; break; } } } return err; } int main(void) { int err = run_tests(); return err; } /a><a href='/cgit.cgi/linux/net-next.git/diff/arch/mips/lantiq/Platform?h=nds-private-remove'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/arch/mips/lantiq/Platform'> <input type='hidden' name='h' value='nds-private-remove'/><select name='qt'> <option value='grep'>log msg</option> <option value='author'>author</option> <option value='committer'>committer</option> <option value='range'>range</option> </select> <input class='txt' type='search' size='10' name='q' value=''/> <input type='submit' value='search'/> </form> </td></tr></table> <div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/commit/?h=nds-private-remove'>root</a>/<a href='/cgit.cgi/linux/net-next.git/commit/arch?h=nds-private-remove'>arch</a>/<a href='/cgit.cgi/linux/net-next.git/commit/arch/mips?h=nds-private-remove'>mips</a>/<a href='/cgit.cgi/linux/net-next.git/commit/arch/mips/lantiq?h=nds-private-remove'>lantiq</a>/<a href='/cgit.cgi/linux/net-next.git/commit/arch/mips/lantiq/Platform?h=nds-private-remove'>Platform</a></div><div class='content'><div class='cgit-panel'><b>diff options</b><form method='get'><input type='hidden' name='h' value='nds-private-remove'/><table><tr><td colspan='2'/></tr><tr><td class='label'>context:</td><td class='ctrl'><select name='context' onchange='this.form.submit();'><option value='1'>1</option><option value='2'>2</option><option value='3' selected='selected'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='15'>15</option><option value='20'>20</option><option value='25'>25</option><option value='30'>30</option><option value='35'>35</option><option value='40'>40</option></select></td></tr><tr><td class='label'>space:</td><td class='ctrl'><select name='ignorews' onchange='this.form.submit();'><option value='0' selected='selected'>include</option><option value='1'>ignore</option></select></td></tr><tr><td class='label'>mode:</td><td class='ctrl'><select name='dt' onchange='this.form.submit();'><option value='0' selected='selected'>unified</option><option value='1'>ssdiff</option><option value='2'>stat only</option></select></td></tr><tr><td/><td class='ctrl'><noscript><input type='submit' value='reload'/></noscript></td></tr></table></form></div><table summary='commit info' class='commit-info'> <tr><th>author</th><td>Tobias Klauser <tklauser@distanz.ch></td><td class='right'>2016-10-20 15:44:19 +0200</td></tr> <tr><th>committer</th><td>Tobias Klauser <tklauser@distanz.ch></td><td class='right'>2017-02-15 10:34:18 +0100</td></tr> <tr><th>commit</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/arch/mips/lantiq/Platform?h=nds-private-remove&id=5db4992d8f040b8d8db0b86d42806e0c417f7ccf'>5db4992d8f040b8d8db0b86d42806e0c417f7ccf</a> (<a href='/cgit.cgi/linux/net-next.git/patch/arch/mips/lantiq/Platform?id=5db4992d8f040b8d8db0b86d42806e0c417f7ccf'>patch</a>)</td></tr> <tr><th>tree</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/tree/?h=nds-private-remove'>5b06e952af482d45f3ade64e77824662e34b7fa2</a> /<a href='/cgit.cgi/linux/net-next.git/tree/arch/mips/lantiq/Platform?h=nds-private-remove'>arch/mips/lantiq/Platform</a></td></tr> <tr><th>parent</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/arch/mips/lantiq/Platform?h=nds-private-remove&id=370ebb0ef6255132373ed35d13e7b1d8d2eb7003'>370ebb0ef6255132373ed35d13e7b1d8d2eb7003</a> (<a href='/cgit.cgi/linux/net-next.git/diff/arch/mips/lantiq/Platform?h=nds-private-remove&id2=370ebb0ef6255132373ed35d13e7b1d8d2eb7003'>diff</a>)</td></tr></table> <div class='commit-subject'>usbnet: pegasus: Use net_device_stats from struct net_device<span class='decoration'><a class='branch-deco' href='/cgit.cgi/linux/net-next.git/log/arch/mips/lantiq/Platform?h=nds-private-remove'>nds-private-remove</a></span></div><div class='commit-msg'>Instead of using a private copy of struct net_device_stats in struct pegasus, use stats from struct net_device. Also remove the now unnecessary .ndo_get_stats function. Cc: Petko Manolov <petkan@nucleusys.com> Cc: linux-usb@vger.kernel.org Signed-off-by: Tobias Klauser <tklauser@distanz.ch> </div><div class='diffstat-header'><a href='/cgit.cgi/linux/net-next.git/diff/?h=nds-private-remove'>Diffstat</a> (limited to 'arch/mips/lantiq/Platform')</div><table summary='diffstat' class='diffstat'>