aboutsummaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2016-09-04 20:55:27 +0000
committerKristof Provost <kp@FreeBSD.org>2016-09-04 20:55:27 +0000
commit9a2ff3154b811a8210a7eca5531e233c69ed5924 (patch)
tree12d81ea7d75d0d61a9df62021c064a4ed9bdcecc /share
parent4e8a91fb6c8ce47a96e80efa93e79d8f55df8310 (diff)
downloadsrc-9a2ff3154b811a8210a7eca5531e233c69ed5924.tar.gz
src-9a2ff3154b811a8210a7eca5531e233c69ed5924.zip
libifconfig: style(9) fixes
Also switch from BSD 3-clause to 2-clause license where possible, and consolidate duplicate 3-clause license into one. Submitted by: Marie Helene Kvello-Aune <marieheleneka@gmail.com> Reviewed by: cem, kp Differential Revision: https://reviews.freebsd.org/D7764
Notes
Notes: svn path=/head/; revision=305395
Diffstat (limited to 'share')
-rw-r--r--share/examples/libifconfig/ifcreate.c59
-rw-r--r--share/examples/libifconfig/ifdestroy.c49
-rw-r--r--share/examples/libifconfig/setdescription.c10
-rw-r--r--share/examples/libifconfig/setmtu.c58
4 files changed, 83 insertions, 93 deletions
diff --git a/share/examples/libifconfig/ifcreate.c b/share/examples/libifconfig/ifcreate.c
index 8f5dde506d2e..7a7fad64d1ed 100644
--- a/share/examples/libifconfig/ifcreate.c
+++ b/share/examples/libifconfig/ifcreate.c
@@ -12,10 +12,6 @@
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
- * 3. Neither the name of the copyright holder nor the names of its contributors
- * may be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -40,16 +36,17 @@
#include <libifconfig.h>
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
+ char *ifname, *ifactualname;
+
if (argc != 2) {
errx(EINVAL, "Invalid number of arguments."
" Only one argument is accepted, and it should be the name"
" of the interface to be created.");
}
- char *ifname, *ifactualname;
-
/* We have a static number of arguments. Therefore we can do it simple. */
ifname = strdup(argv[1]);
@@ -63,31 +60,31 @@ int main(int argc, char *argv[])
free(ifname);
free(ifactualname);
return (0);
- } else {
- switch (ifconfig_err_errtype(lifh)) {
- case SOCKET:
- warnx("couldn't create socket. This shouldn't happen.\n");
- break;
- case IOCTL:
- if (ifconfig_err_ioctlreq(lifh) == SIOCIFCREATE2) {
- warnx(
- "Failed to create interface (SIOCIFCREATE2)\n");
- }
- break;
- default:
+ }
+
+ switch (ifconfig_err_errtype(lifh)) {
+ case SOCKET:
+ warnx("couldn't create socket. This shouldn't happen.\n");
+ break;
+ case IOCTL:
+ if (ifconfig_err_ioctlreq(lifh) == SIOCIFCREATE2) {
warnx(
- "This is a thorough example accommodating for temporary"
- " 'not implemented yet' errors. That's likely what happened"
- " now. If not, your guess is as good as mine. ;)"
- " Error code: %d\n", ifconfig_err_errno(
- lifh));
- break;
+ "Failed to create interface (SIOCIFCREATE2)\n");
}
-
- ifconfig_close(lifh);
- lifh = NULL;
- free(ifname);
- free(ifactualname);
- return (-1);
+ break;
+ default:
+ warnx(
+ "This is a thorough example accommodating for temporary"
+ " 'not implemented yet' errors. That's likely what happened"
+ " now. If not, your guess is as good as mine. ;)"
+ " Error code: %d\n", ifconfig_err_errno(
+ lifh));
+ break;
}
+
+ ifconfig_close(lifh);
+ lifh = NULL;
+ free(ifname);
+ free(ifactualname);
+ return (-1);
}
diff --git a/share/examples/libifconfig/ifdestroy.c b/share/examples/libifconfig/ifdestroy.c
index 029e70a8d9b0..4dd556f9d8c8 100644
--- a/share/examples/libifconfig/ifdestroy.c
+++ b/share/examples/libifconfig/ifdestroy.c
@@ -12,10 +12,6 @@
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
- * 3. Neither the name of the copyright holder nor the names of its contributors
- * may be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -40,16 +36,17 @@
#include <libifconfig.h>
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
+ char *ifname;
+
if (argc != 2) {
errx(EINVAL, "Invalid number of arguments."
" Only one argument is accepted, and it should be the name"
" of the interface to be destroyed.");
}
- char *ifname;
-
/* We have a static number of arguments. Therefore we can do it simple. */
ifname = strdup(argv[1]);
@@ -62,26 +59,26 @@ int main(int argc, char *argv[])
lifh = NULL;
free(ifname);
return (0);
- } else {
- switch (ifconfig_err_errtype(lifh)) {
- case SOCKET:
- warnx("couldn't create socket. This shouldn't happen.\n");
- break;
- case IOCTL:
- if (ifconfig_err_ioctlreq(lifh) == SIOCIFDESTROY) {
- warnx(
- "Failed to destroy interface (SIOCIFDESTROY)\n");
- }
- break;
- default:
+ }
+
+ switch (ifconfig_err_errtype(lifh)) {
+ case SOCKET:
+ warnx("couldn't create socket. This shouldn't happen.\n");
+ break;
+ case IOCTL:
+ if (ifconfig_err_ioctlreq(lifh) == SIOCIFDESTROY) {
warnx(
- "Should basically never end up here in this example.\n");
- break;
+ "Failed to destroy interface (SIOCIFDESTROY)\n");
}
-
- ifconfig_close(lifh);
- lifh = NULL;
- free(ifname);
- return (-1);
+ break;
+ default:
+ warnx(
+ "Should basically never end up here in this example.\n");
+ break;
}
+
+ ifconfig_close(lifh);
+ lifh = NULL;
+ free(ifname);
+ return (-1);
}
diff --git a/share/examples/libifconfig/setdescription.c b/share/examples/libifconfig/setdescription.c
index 656aba75976f..371b49729379 100644
--- a/share/examples/libifconfig/setdescription.c
+++ b/share/examples/libifconfig/setdescription.c
@@ -12,10 +12,6 @@
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
- * 3. Neither the name of the copyright holder nor the names of its contributors
- * may be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -38,15 +34,17 @@
#include <libifconfig.h>
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
+ char *ifname, *ifdescr, *curdescr;
+
if (argc != 3) {
errx(EINVAL, "Invalid number of arguments."
" First argument should be interface name, second argument"
" should be the description to set.");
}
- char *ifname, *ifdescr, *curdescr;
/* We have a static number of arguments. Therefore we can do it simple. */
ifname = strdup(argv[1]);
ifdescr = strdup(argv[2]);
diff --git a/share/examples/libifconfig/setmtu.c b/share/examples/libifconfig/setmtu.c
index 4d5a0f8d5f92..1f8f33873ecf 100644
--- a/share/examples/libifconfig/setmtu.c
+++ b/share/examples/libifconfig/setmtu.c
@@ -12,9 +12,6 @@
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
- * 3. Neither the name of the copyright holder nor the names of its contributors
- * may be used to endorse or promote products derived from this software without
- * specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
@@ -40,17 +37,18 @@
#include <libifconfig.h>
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
+ char *ifname, *ptr;
+ int mtu;
+
if (argc != 3) {
errx(EINVAL, "Invalid number of arguments."
" First argument should be interface name, second argument"
" should be the MTU to set.");
}
- char *ifname, *ptr;
- int mtu;
-
/* We have a static number of arguments. Therefore we can do it simple. */
ifname = strdup(argv[1]);
mtu = (int)strtol(argv[2], &ptr, 10);
@@ -65,30 +63,30 @@ int main(int argc, char *argv[])
lifh = NULL;
free(ifname);
return (0);
- } else {
- switch (ifconfig_err_errtype(lifh)) {
- case SOCKET:
- warnx("couldn't create socket. This shouldn't happen.\n");
- break;
- case IOCTL:
- if (ifconfig_err_ioctlreq(lifh) == SIOCSIFMTU) {
- warnx("Failed to set MTU (SIOCSIFMTU)\n");
- } else {
- warnx(
- "Failed to set MTU due to error in unexpected ioctl() call %lu. Error code: %i.\n",
- ifconfig_err_ioctlreq(lifh),
- ifconfig_err_errno(lifh));
- }
- break;
- default:
+ }
+
+ switch (ifconfig_err_errtype(lifh)) {
+ case SOCKET:
+ warnx("couldn't create socket. This shouldn't happen.\n");
+ break;
+ case IOCTL:
+ if (ifconfig_err_ioctlreq(lifh) == SIOCSIFMTU) {
+ warnx("Failed to set MTU (SIOCSIFMTU)\n");
+ } else {
warnx(
- "Should basically never end up here in this example.\n");
- break;
+ "Failed to set MTU due to error in unexpected ioctl() call %lu. Error code: %i.\n",
+ ifconfig_err_ioctlreq(lifh),
+ ifconfig_err_errno(lifh));
}
-
- ifconfig_close(lifh);
- lifh = NULL;
- free(ifname);
- return (-1);
+ break;
+ default:
+ warnx(
+ "Should basically never end up here in this example.\n");
+ break;
}
+
+ ifconfig_close(lifh);
+ lifh = NULL;
+ free(ifname);
+ return (-1);
}