1.1 --- a/librazor/root.c Sun Jun 29 10:55:17 2008 +0100
1.2 +++ b/librazor/root.c Mon Jun 30 09:47:32 2008 +0100
1.3 @@ -24,6 +24,8 @@
1.4 #include <dirent.h>
1.5 #include <unistd.h>
1.6 #include <fcntl.h>
1.7 +#include <assert.h>
1.8 +
1.9 #include "razor.h"
1.10 #include "razor-internal.h"
1.11
1.12 @@ -49,6 +51,8 @@
1.13 struct razor_set *set;
1.14 char path[PATH_MAX], details_path[PATH_MAX], files_path[PATH_MAX];
1.15
1.16 + assert (root != NULL);
1.17 +
1.18 if (stat(root, &buf) < 0) {
1.19 if (mkdir(root, 0777) < 0) {
1.20 fprintf(stderr,
1.21 @@ -100,6 +104,8 @@
1.22 {
1.23 struct razor_root *image;
1.24
1.25 + assert (root != NULL);
1.26 +
1.27 image = malloc(sizeof *image);
1.28 if (image == NULL)
1.29 return NULL;
1.30 @@ -140,6 +146,8 @@
1.31 {
1.32 char path[PATH_MAX];
1.33
1.34 + assert (root != NULL);
1.35 +
1.36 snprintf(path, sizeof path, "%s%s/%s",
1.37 root, razor_root_path, system_repo_filename);
1.38
1.39 @@ -149,12 +157,16 @@
1.40 RAZOR_EXPORT struct razor_set *
1.41 razor_root_get_system_set(struct razor_root *root)
1.42 {
1.43 + assert (root != NULL);
1.44 +
1.45 return root->system;
1.46 }
1.47
1.48 RAZOR_EXPORT int
1.49 razor_root_close(struct razor_root *root)
1.50 {
1.51 + assert (root != NULL);
1.52 +
1.53 razor_set_destroy(root->system);
1.54 unlink(root->new_path);
1.55 close(root->fd);
1.56 @@ -166,6 +178,9 @@
1.57 RAZOR_EXPORT void
1.58 razor_root_update(struct razor_root *root, struct razor_set *next)
1.59 {
1.60 + assert (root != NULL);
1.61 + assert (next != NULL);
1.62 +
1.63 razor_set_write_to_fd(next, root->fd, RAZOR_REPO_FILE_MAIN);
1.64 root->next = next;
1.65
1.66 @@ -178,6 +193,8 @@
1.67 RAZOR_EXPORT int
1.68 razor_root_commit(struct razor_root *root)
1.69 {
1.70 + assert (root != NULL);
1.71 +
1.72 /* Make it so. */
1.73 rename(root->new_path, root->path);
1.74 printf("renamed %s to %s\n", root->new_path, root->path);