tools: normalize nfdc exit codes

refs #3749

Change-Id: I0c81dff095c170390f62de82badc0cca7b53392d
diff --git a/docs/manpages/nfd-status.rst b/docs/manpages/nfd-status.rst
index f22f326..a7ec024 100644
--- a/docs/manpages/nfd-status.rst
+++ b/docs/manpages/nfd-status.rst
@@ -47,6 +47,15 @@
 
 If -x is provided, other options(-v, -c, etc.) are ignored, and all information is printed in XML format.
 
+Exit Codes
+----------
+
+0: Success
+
+1: An unspecified error occurred
+
+2: Malformed command line
+
 Examples
 --------
 
diff --git a/docs/manpages/nfdc.rst b/docs/manpages/nfdc.rst
index d06b519..c6fb3b8 100644
--- a/docs/manpages/nfdc.rst
+++ b/docs/manpages/nfdc.rst
@@ -181,7 +181,14 @@
         Note that when ``faceId`` is the last Face associated with ``prefix`` FIB entry,
         the whole FIB entry will be removed.
 
+Exit Codes
+----------
 
+0: Success
+
+1: An unspecified error occurred
+
+2: Malformed command line
 
 Examples
 --------
diff --git a/tools/nfdc/legacy-nfdc.cpp b/tools/nfdc/legacy-nfdc.cpp
index f5c4fa7..467789e 100644
--- a/tools/nfdc/legacy-nfdc.cpp
+++ b/tools/nfdc/legacy-nfdc.cpp
@@ -357,7 +357,7 @@
   catch (const po::error& e) {
     std::cerr << e.what() << std::endl;
     legacyNfdcUsage();
-    return 1;
+    return 2;
   }
 
   if (wantUnsetChildInherit) {
@@ -378,14 +378,14 @@
       [] (const std::string& s) { return s.empty() || s[0] == '-'; })) {
     // unrecognized -option
     legacyNfdcUsage();
-    return 1;
+    return 2;
   }
   p.m_commandLineArguments = unparsed;
 
   bool isOk = p.dispatch(subcommand);
   if (!isOk) {
     legacyNfdcUsage();
-    return 1;
+    return 2;
   }
   ctx.face.processEvents();
   return 0;
diff --git a/tools/nfdc/main.cpp b/tools/nfdc/main.cpp
index c578407..bcd9da3 100644
--- a/tools/nfdc/main.cpp
+++ b/tools/nfdc/main.cpp
@@ -56,7 +56,7 @@
   }
   catch (const std::invalid_argument& e) {
     std::cerr << e.what() << std::endl;
-    return 1;
+    return 2;
   }
 
   try {