util: Add extra max_size argument to file_lines_load()
authorMartin Schwenke <martin@meltin.net>
Fri, 15 Aug 2014 06:11:45 +0000 (16:11 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 27 Mar 2015 02:54:51 +0000 (13:54 +1100)
This is part of a migration to Samba's lib/util.  CTDB always passes 0
(i.e. no max_size) so use a simple assert() to enforce this, rather
than changing a lot of code that will be discarded anyway.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit a4e76b58a5086e1339dea53b72437ed179e6025a)

include/internal/includes.h
lib/util/util_file.c
server/ctdb_server.c
server/ctdb_takeover.c
tools/ctdb.c

index d5ac697beb1cbb20df936169ab2bc561d4544324..db87d66ddc6b84e4e5c61c374463068fdac906c1 100644 (file)
@@ -56,7 +56,7 @@ struct timeval timeval_until(const struct timeval *tv1,
 _PUBLIC_ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs);
 double timeval_elapsed(struct timeval *tv);
 double timeval_delta(struct timeval *tv2, struct timeval *tv);
-char **file_lines_load(const char *fname, int *numlines, TALLOC_CTX *mem_ctx);
+char **file_lines_load(const char *fname, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx);
 char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len);
 _PUBLIC_ int set_blocking(int fd, bool set);
 
index 21d64b20e3dab574b9d872bce71cebbcbfc05bae..5db007206185cc49541f75bec6162a1c10afd019 100644 (file)
@@ -3,6 +3,8 @@
   not intended to remain part of ctdb
 */
 
+#include <assert.h>
+
 #include "includes.h"
 #include "system/filesys.h"
 
@@ -91,11 +93,13 @@ static char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *
 load a file into memory and return an array of pointers to lines in the file
 must be freed with talloc_free(). 
 **/
-_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, TALLOC_CTX *mem_ctx)
+_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx)
 {
        char *p;
        size_t size;
 
+       assert(maxsize == 0);
+
        p = file_load(fname, &size, mem_ctx);
        if (!p) return NULL;
 
index 54758957cd4157236f7687311f3d57555e544287..2598c4cb5b3aa41220501606d5eab89591b0b32a 100644 (file)
@@ -170,7 +170,7 @@ static int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist)
        ctdb->nodes     = NULL;
        ctdb->num_nodes = 0;
 
-       lines = file_lines_load(nlist, &nlines, ctdb);
+       lines = file_lines_load(nlist, &nlines, 0, ctdb);
        if (lines == NULL) {
                ctdb_set_error(ctdb, "Failed to load nlist '%s'\n", nlist);
                return -1;
index eeb435324feb2b7e2339d034aec6bed6feff83b1..ba476d169f4fa0f76b8c805b82e76ca38ce7a8fd 100644 (file)
@@ -1186,7 +1186,7 @@ int ctdb_set_public_addresses(struct ctdb_context *ctdb, bool check_addresses)
        int nlines;
        int i;
 
-       lines = file_lines_load(ctdb->public_addresses_file, &nlines, ctdb);
+       lines = file_lines_load(ctdb->public_addresses_file, &nlines, 0, ctdb);
        if (lines == NULL) {
                ctdb_set_error(ctdb, "Failed to load public address list '%s'\n", ctdb->public_addresses_file);
                return -1;
index 2a9e1e8868f25ee683687fac7e183edbcb35e7a2..608d50a3000953be14f0846441aa605d224d9a9f 100644 (file)
@@ -858,7 +858,7 @@ static struct pnn_node *read_pnn_node_file(TALLOC_CTX *mem_ctx,
        struct pnn_node *pnn_nodes = NULL;
        struct pnn_node *pnn_node;
 
-       lines = file_lines_load(file, &nlines, mem_ctx);
+       lines = file_lines_load(file, &nlines, 0, mem_ctx);
        if (lines == NULL) {
                return NULL;
        }