From 419df715dabaa4d031153be5f7ca2cbea5715951 Mon Sep 17 00:00:00 2001 From: JensHoffmann Date: Thu, 12 Dec 2013 23:03:35 +0100 Subject: [PATCH] Lint help and usage in oned.cc (cherry picked from commit d9b6cca19589db2b76443edf3bc683c8dac016db) Conflicts: src/nebula/oned.cc --- src/nebula/oned.cc | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/nebula/oned.cc b/src/nebula/oned.cc index 5a3e7b90a2..f4db6145a4 100644 --- a/src/nebula/oned.cc +++ b/src/nebula/oned.cc @@ -18,28 +18,13 @@ #include #include #include +#include +#include #include "Nebula.h" using namespace std; -/* ------------------------------------------------------------------------- */ -/* GLOBAL VARIABLES */ -/* ------------------------------------------------------------------------- */ - -static const char * usage = -"\n oned [-h] [-v] [-f]\n\n" -"SYNOPSIS\n" -" Starts the OpenNebula daemon\n\n" -"OPTIONS\n" -"\t-v\tprints OpenNebula version and license\n" -"\t-h\tprints this help.\n" -"\t-f\tforeground, do not fork the oned daemon\n" -"\t-i\tinitialize the dabase and exit.\n"; - -static const char * susage = -"usage: oned [-h] [-v] [-f]\n"; - /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -51,6 +36,25 @@ static void print_license() << "(http://www.apache.org/licenses/LICENSE-2.0).\n"; } +static void print_usage(ostream& str) +{ + str << "Usage: oned [-h] [-v] [-f] [-i]\n"; +} + +static void print_help() +{ + print_usage(cout); + + cout << "\n" + << "SYNOPSIS\n" + << " Starts the OpenNebula daemon\n\n" + << "OPTIONS\n" + << " -v\toutput version information and exit\n" + << " -h\tdisplay this help and exit\n" + << " -f\tforeground, do not fork the oned daemon\n" + << " -i\tinitialize the dabase and exit\n"; +} + /* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */ @@ -108,7 +112,7 @@ int main(int argc, char **argv) exit(0); break; case 'h': - cout << usage; + print_help(); exit(0); break; case 'i': @@ -119,7 +123,7 @@ int main(int argc, char **argv) foreground = true; break; default: - cerr << susage; + print_usage(cerr); exit(-1); break; }