[libvirt] [PATCH 1/4] examples: Properly include getopt.h

Michal Privoznik mprivozn at redhat.com
Thu Apr 27 07:01:57 UTC 2017


In the admin/logging.c example, the getopt() function is used but
without proper #include. It relies on unistd.h to subsequently
include getopt.h. This is not necessarily always the case.
Also, opterr is not needed and actually not used anywhere else in
our code.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 examples/admin/logging.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/examples/admin/logging.c b/examples/admin/logging.c
index 648d7a6..de258c2 100644
--- a/examples/admin/logging.c
+++ b/examples/admin/logging.c
@@ -1,11 +1,12 @@
-#include<stdio.h>
-#include<stdlib.h>
-#include<stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
 
 #include "config.h"
-#include<unistd.h>
-#include<libvirt/libvirt-admin.h>
-#include<libvirt/virterror.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <libvirt/libvirt-admin.h>
+#include <libvirt/virterror.h>
 
 static void printHelp(const char *argv0)
 {
@@ -31,7 +32,6 @@ int main(int argc, char **argv)
     const char *set_filters = NULL;
 
     ret = c = -1;
-    opterr = 0;
 
     while ((c = getopt(argc, argv, ":hpo:f:")) > 0) {
         switch (c) {
-- 
2.10.2




More information about the libvir-list mailing list