Minor fixes
authorWouter Verhelst <w@uter.be>
Wed, 7 Jan 2009 12:10:11 +0000 (13:10 +0100)
committerWouter Verhelst <w@uter.be>
Wed, 7 Jan 2009 12:10:11 +0000 (13:10 +0100)
- Gracefully handle when a config file contains a valid [generic] section, but
  no export sections
- Free our key file stuff on successful parsing of the config file, too.

nbd-server.c

index bc390ab..754d21a 100644 (file)
@@ -512,7 +512,9 @@ typedef enum {
        CFILE_KEY_MISSING,      /**< A (required) key is missing */
        CFILE_VALUE_INVALID,    /**< A value is syntactically invalid */
        CFILE_VALUE_UNSUPPORTED,/**< A value is not supported in this build */
-       CFILE_PROGERR           /**< Programmer error */
+       CFILE_PROGERR,          /**< Programmer error */
+       CFILE_NO_EXPORTS        /**< A config file was specified that does not
+                                    define any exports */
 } CFILE_ERRORS;
 
 /**
@@ -705,6 +707,10 @@ GArray* parse_cfile(gchar* f, GError** e) {
                }
 #endif
        }
+       if(i==1) {
+               g_set_error(e, errdomain, CFILE_NO_EXPORTS, "The config file does not specify any exports");
+       }
+       g_key_file_free(cfile);
        return retval;
 }