Bug Summary

File:libglusterfs/src/graph.c
Location:line 531, column 20
Description:Access to field 'first' results in a dereference of a null pointer (loaded from variable 'newgraph')

Annotated Source Code

1/*
2 Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
3 This file is part of GlusterFS.
4
5 This file is licensed to you under your choice of the GNU Lesser
6 General Public License, version 3 or any later version (LGPLv3 or
7 later), or the GNU General Public License, version 2 (GPLv2), in all
8 cases as published by the Free Software Foundation.
9*/
10
11#ifndef _CONFIG_H
12#define _CONFIG_H
13#include "config.h"
14#endif
15
16#include "xlator.h"
17#include <dlfcn.h>
18#include <netdb.h>
19#include <fnmatch.h>
20#include "defaults.h"
21
22
23#if 0
24static void
25_gf_dump_details (int argc, char **argv)
26{
27 extern FILE *gf_log_logfile;
28 int i = 0;
29 char timestr[64];
30 time_t utime = 0;
31 pid_t mypid = 0;
32 struct utsname uname_buf = {{0, }, };
33 int uname_ret = -1;
34
35 mypid = getpid ();
36 uname_ret = uname (&uname_buf);
37
38 utime = time (NULL((void*)0));
39 gf_time_fmt (timestr, sizeof timestr, utime, gf_timefmt_FT);
40 fprintf (gf_log_logfile,
41 "========================================"
42 "========================================\n");
43 fprintf (gf_log_logfile, "Version : %s %s built on %s %s\n",
44 PACKAGE_NAME"glusterfs", PACKAGE_VERSION"3git", __DATE__"May 5 2013", __TIME__"11:17:46");
45 fprintf (gf_log_logfile, "git: %s\n",
46 GLUSTERFS_REPOSITORY_REVISION);
47 fprintf (gf_log_logfile, "Starting Time: %s\n", timestr);
48 fprintf (gf_log_logfile, "Command line : ");
49 for (i = 0; i < argc; i++) {
50 fprintf (gf_log_logfile, "%s ", argv[i]);
51 }
52
53 fprintf (gf_log_logfile, "\nPID : %d\n", mypid);
54
55 if (uname_ret == 0) {
56 fprintf (gf_log_logfile, "System name : %s\n",
57 uname_buf.sysname);
58 fprintf (gf_log_logfile, "Nodename : %s\n",
59 uname_buf.nodename);
60 fprintf (gf_log_logfile, "Kernel Release : %s\n",
61 uname_buf.release);
62 fprintf (gf_log_logfile, "Hardware Identifier: %s\n",
63 uname_buf.machine);
64 }
65
66
67 fprintf (gf_log_logfile, "\n");
68 fflush (gf_log_logfile);
69}
70#endif
71
72
73
74int
75glusterfs_xlator_link (xlator_t *pxl, xlator_t *cxl)
76{
77 xlator_list_t *xlchild = NULL((void*)0);
78 xlator_list_t *xlparent = NULL((void*)0);
79 xlator_list_t **tmp = NULL((void*)0);
80
81 xlparent = (void *) GF_CALLOC (1, sizeof (*xlparent),__gf_calloc (1, sizeof (*xlparent), gf_common_mt_xlator_list_t
)
82 gf_common_mt_xlator_list_t)__gf_calloc (1, sizeof (*xlparent), gf_common_mt_xlator_list_t
)
;
83 if (!xlparent)
84 return -1;
85
86 xlchild = (void *) GF_CALLOC (1, sizeof (*xlchild),__gf_calloc (1, sizeof (*xlchild), gf_common_mt_xlator_list_t
)
87 gf_common_mt_xlator_list_t)__gf_calloc (1, sizeof (*xlchild), gf_common_mt_xlator_list_t
)
;
88 if (!xlchild) {
89 GF_FREE (xlparent)__gf_free (xlparent);
90
91 return -1;
92 }
93
94 xlparent->xlator = pxl;
95 for (tmp = &cxl->parents; *tmp; tmp = &(*tmp)->next);
96 *tmp = xlparent;
97
98 xlchild->xlator = cxl;
99 for (tmp = &pxl->children; *tmp; tmp = &(*tmp)->next);
100 *tmp = xlchild;
101
102 return 0;
103}
104
105
106void
107glusterfs_graph_set_first (glusterfs_graph_t *graph, xlator_t *xl)
108{
109 xl->next = graph->first;
110 if (graph->first)
111 ((xlator_t *)graph->first)->prev = xl;
112 graph->first = xl;
113
114 graph->xl_count++;
115}
116
117
118int
119glusterfs_graph_insert (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx,
120 const char *type, const char *name,
121 gf_boolean_t autoload)
122{
123 xlator_t *ixl = NULL((void*)0);
124
125 if (!ctx->master) {
126 gf_log ("glusterfs", GF_LOG_ERROR,do { do { if (0) printf ("volume \"%s\" can be added from command line only "
"on client side", type); } while (0); _gf_log ("glusterfs", "graph.c"
, __FUNCTION__, 128, GF_LOG_ERROR, "volume \"%s\" can be added from command line only "
"on client side", type); } while (0)
127 "volume \"%s\" can be added from command line only "do { do { if (0) printf ("volume \"%s\" can be added from command line only "
"on client side", type); } while (0); _gf_log ("glusterfs", "graph.c"
, __FUNCTION__, 128, GF_LOG_ERROR, "volume \"%s\" can be added from command line only "
"on client side", type); } while (0)
128 "on client side", type)do { do { if (0) printf ("volume \"%s\" can be added from command line only "
"on client side", type); } while (0); _gf_log ("glusterfs", "graph.c"
, __FUNCTION__, 128, GF_LOG_ERROR, "volume \"%s\" can be added from command line only "
"on client side", type); } while (0)
;
129
130 return -1;
131 }
132
133 ixl = GF_CALLOC (1, sizeof (*ixl), gf_common_mt_xlator_t)__gf_calloc (1, sizeof (*ixl), gf_common_mt_xlator_t);
134 if (!ixl)
135 return -1;
136
137 ixl->ctx = ctx;
138 ixl->graph = graph;
139 ixl->options = get_new_dict ();
140 if (!ixl->options)
141 goto err;
142
143 ixl->name = gf_strdup (name);
144 if (!ixl->name)
145 goto err;
146
147 ixl->is_autoloaded = autoload;
148
149 if (xlator_set_type (ixl, type) == -1) {
150 gf_log ("glusterfs", GF_LOG_ERROR,do { do { if (0) printf ("%s (%s) initialization failed", name
, type); } while (0); _gf_log ("glusterfs", "graph.c", __FUNCTION__
, 152, GF_LOG_ERROR, "%s (%s) initialization failed", name, type
); } while (0)
151 "%s (%s) initialization failed",do { do { if (0) printf ("%s (%s) initialization failed", name
, type); } while (0); _gf_log ("glusterfs", "graph.c", __FUNCTION__
, 152, GF_LOG_ERROR, "%s (%s) initialization failed", name, type
); } while (0)
152 name, type)do { do { if (0) printf ("%s (%s) initialization failed", name
, type); } while (0); _gf_log ("glusterfs", "graph.c", __FUNCTION__
, 152, GF_LOG_ERROR, "%s (%s) initialization failed", name, type
); } while (0)
;
153 return -1;
154 }
155
156 if (glusterfs_xlator_link (ixl, graph->top) == -1)
157 goto err;
158 glusterfs_graph_set_first (graph, ixl);
159 graph->top = ixl;
160
161 return 0;
162err:
163 xlator_destroy (ixl);
164 return -1;
165}
166
167int
168glusterfs_graph_acl (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
169{
170 int ret = 0;
171 cmd_args_t *cmd_args = NULL((void*)0);
172
173 cmd_args = &ctx->cmd_args;
174
175 if (!cmd_args->acl)
176 return 0;
177
178 ret = glusterfs_graph_insert (graph, ctx, "system/posix-acl",
179 "posix-acl-autoload", 1);
180 return ret;
181}
182
183int
184glusterfs_graph_worm (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
185{
186 int ret = 0;
187 cmd_args_t *cmd_args = NULL((void*)0);
188
189 cmd_args = &ctx->cmd_args;
190
191 if (!cmd_args->worm)
192 return 0;
193
194 ret = glusterfs_graph_insert (graph, ctx, "features/worm",
195 "worm-autoload", 1);
196 return ret;
197}
198
199int
200glusterfs_graph_mac_compat (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
201{
202 int ret = 0;
203 cmd_args_t *cmd_args = NULL((void*)0);
204
205 cmd_args = &ctx->cmd_args;
206
207 if (cmd_args->mac_compat == GF_OPTION_DISABLE_gf_false)
208 return 0;
209
210 ret = glusterfs_graph_insert (graph, ctx, "features/mac-compat",
211 "mac-compat-autoload", 1);
212
213 return ret;
214}
215
216
217static void
218gf_add_cmdline_options (glusterfs_graph_t *graph, cmd_args_t *cmd_args)
219{
220 int ret = 0;
221 xlator_t *trav = NULL((void*)0);
222 xlator_cmdline_option_t *cmd_option = NULL((void*)0);
223
224 trav = graph->first;
225
226 while (trav) {
227 list_for_each_entry (cmd_option,for (cmd_option = ((typeof(*cmd_option) *)((char *)((&cmd_args
->xlator_options)->next)-(unsigned long)(&((typeof(
*cmd_option) *)0)->cmd_args))); &cmd_option->cmd_args
!= (&cmd_args->xlator_options); cmd_option = ((typeof
(*cmd_option) *)((char *)(cmd_option->cmd_args.next)-(unsigned
long)(&((typeof(*cmd_option) *)0)->cmd_args))))
228 &cmd_args->xlator_options, cmd_args)for (cmd_option = ((typeof(*cmd_option) *)((char *)((&cmd_args
->xlator_options)->next)-(unsigned long)(&((typeof(
*cmd_option) *)0)->cmd_args))); &cmd_option->cmd_args
!= (&cmd_args->xlator_options); cmd_option = ((typeof
(*cmd_option) *)((char *)(cmd_option->cmd_args.next)-(unsigned
long)(&((typeof(*cmd_option) *)0)->cmd_args))))
{
229 if (!fnmatch (cmd_option->volume,
230 trav->name, FNM_NOESCAPE(1 << 1))) {
231 ret = dict_set_str (trav->options,
232 cmd_option->key,
233 cmd_option->value);
234 if (ret == 0) {
235 gf_log (trav->name, GF_LOG_INFO,do { do { if (0) printf ("adding option '%s' for " "volume '%s' with value '%s'"
, cmd_option->key, trav->name, cmd_option->value); }
while (0); _gf_log (trav->name, "graph.c", __FUNCTION__, 239
, GF_LOG_INFO, "adding option '%s' for " "volume '%s' with value '%s'"
, cmd_option->key, trav->name, cmd_option->value); }
while (0)
236 "adding option '%s' for "do { do { if (0) printf ("adding option '%s' for " "volume '%s' with value '%s'"
, cmd_option->key, trav->name, cmd_option->value); }
while (0); _gf_log (trav->name, "graph.c", __FUNCTION__, 239
, GF_LOG_INFO, "adding option '%s' for " "volume '%s' with value '%s'"
, cmd_option->key, trav->name, cmd_option->value); }
while (0)
237 "volume '%s' with value '%s'",do { do { if (0) printf ("adding option '%s' for " "volume '%s' with value '%s'"
, cmd_option->key, trav->name, cmd_option->value); }
while (0); _gf_log (trav->name, "graph.c", __FUNCTION__, 239
, GF_LOG_INFO, "adding option '%s' for " "volume '%s' with value '%s'"
, cmd_option->key, trav->name, cmd_option->value); }
while (0)
238 cmd_option->key, trav->name,do { do { if (0) printf ("adding option '%s' for " "volume '%s' with value '%s'"
, cmd_option->key, trav->name, cmd_option->value); }
while (0); _gf_log (trav->name, "graph.c", __FUNCTION__, 239
, GF_LOG_INFO, "adding option '%s' for " "volume '%s' with value '%s'"
, cmd_option->key, trav->name, cmd_option->value); }
while (0)
239 cmd_option->value)do { do { if (0) printf ("adding option '%s' for " "volume '%s' with value '%s'"
, cmd_option->key, trav->name, cmd_option->value); }
while (0); _gf_log (trav->name, "graph.c", __FUNCTION__, 239
, GF_LOG_INFO, "adding option '%s' for " "volume '%s' with value '%s'"
, cmd_option->key, trav->name, cmd_option->value); }
while (0)
;
240 } else {
241 gf_log (trav->name, GF_LOG_WARNING,do { do { if (0) printf ("adding option '%s' for " "volume '%s' failed: %s"
, cmd_option->key, trav->name, strerror (-ret)); } while
(0); _gf_log (trav->name, "graph.c", __FUNCTION__, 245, GF_LOG_WARNING
, "adding option '%s' for " "volume '%s' failed: %s", cmd_option
->key, trav->name, strerror (-ret)); } while (0)
242 "adding option '%s' for "do { do { if (0) printf ("adding option '%s' for " "volume '%s' failed: %s"
, cmd_option->key, trav->name, strerror (-ret)); } while
(0); _gf_log (trav->name, "graph.c", __FUNCTION__, 245, GF_LOG_WARNING
, "adding option '%s' for " "volume '%s' failed: %s", cmd_option
->key, trav->name, strerror (-ret)); } while (0)
243 "volume '%s' failed: %s",do { do { if (0) printf ("adding option '%s' for " "volume '%s' failed: %s"
, cmd_option->key, trav->name, strerror (-ret)); } while
(0); _gf_log (trav->name, "graph.c", __FUNCTION__, 245, GF_LOG_WARNING
, "adding option '%s' for " "volume '%s' failed: %s", cmd_option
->key, trav->name, strerror (-ret)); } while (0)
244 cmd_option->key, trav->name,do { do { if (0) printf ("adding option '%s' for " "volume '%s' failed: %s"
, cmd_option->key, trav->name, strerror (-ret)); } while
(0); _gf_log (trav->name, "graph.c", __FUNCTION__, 245, GF_LOG_WARNING
, "adding option '%s' for " "volume '%s' failed: %s", cmd_option
->key, trav->name, strerror (-ret)); } while (0)
245 strerror (-ret))do { do { if (0) printf ("adding option '%s' for " "volume '%s' failed: %s"
, cmd_option->key, trav->name, strerror (-ret)); } while
(0); _gf_log (trav->name, "graph.c", __FUNCTION__, 245, GF_LOG_WARNING
, "adding option '%s' for " "volume '%s' failed: %s", cmd_option
->key, trav->name, strerror (-ret)); } while (0)
;
246 }
247 }
248 }
249 trav = trav->next;
250 }
251}
252
253
254int
255glusterfs_graph_validate_options (glusterfs_graph_t *graph)
256{
257 xlator_t *trav = NULL((void*)0);
258 int ret = -1;
259 char *errstr = NULL((void*)0);
260
261 trav = graph->first;
262
263 while (trav) {
264 if (list_empty (&trav->volume_options))
265 continue;
266
267 ret = xlator_options_validate (trav, trav->options, &errstr);
268 if (ret) {
269 gf_log (trav->name, GF_LOG_ERROR,do { do { if (0) printf ("validation failed: %s", errstr); } while
(0); _gf_log (trav->name, "graph.c", __FUNCTION__, 270, GF_LOG_ERROR
, "validation failed: %s", errstr); } while (0)
270 "validation failed: %s", errstr)do { do { if (0) printf ("validation failed: %s", errstr); } while
(0); _gf_log (trav->name, "graph.c", __FUNCTION__, 270, GF_LOG_ERROR
, "validation failed: %s", errstr); } while (0)
;
271 return ret;
272 }
273 trav = trav->next;
274 }
275
276 return 0;
277}
278
279
280int
281glusterfs_graph_init (glusterfs_graph_t *graph)
282{
283 xlator_t *trav = NULL((void*)0);
284 int ret = -1;
285
286 trav = graph->first;
287
288 while (trav) {
289 ret = xlator_init (trav);
290 if (ret) {
291 gf_log (trav->name, GF_LOG_ERROR,do { do { if (0) printf ("initializing translator failed"); }
while (0); _gf_log (trav->name, "graph.c", __FUNCTION__, 292
, GF_LOG_ERROR, "initializing translator failed"); } while (0
)
292 "initializing translator failed")do { do { if (0) printf ("initializing translator failed"); }
while (0); _gf_log (trav->name, "graph.c", __FUNCTION__, 292
, GF_LOG_ERROR, "initializing translator failed"); } while (0
)
;
293 return ret;
294 }
295 trav = trav->next;
296 }
297
298 return 0;
299}
300
301
302static int
303_log_if_unknown_option (dict_t *dict, char *key, data_t *value, void *data)
304{
305 volume_option_t *found = NULL((void*)0);
306 xlator_t *xl = NULL((void*)0);
307
308 xl = data;
309
310 found = xlator_volume_option_get (xl, key);
311
312 if (!found) {
313 gf_log (xl->name, GF_LOG_WARNING,do { do { if (0) printf ("option '%s' is not recognized", key
); } while (0); _gf_log (xl->name, "graph.c", __FUNCTION__
, 314, GF_LOG_WARNING, "option '%s' is not recognized", key);
} while (0)
314 "option '%s' is not recognized", key)do { do { if (0) printf ("option '%s' is not recognized", key
); } while (0); _gf_log (xl->name, "graph.c", __FUNCTION__
, 314, GF_LOG_WARNING, "option '%s' is not recognized", key);
} while (0)
;
315 }
316
317 return 0;
318}
319
320
321static void
322_xlator_check_unknown_options (xlator_t *xl, void *data)
323{
324 dict_foreach (xl->options, _log_if_unknown_option, xl);
325}
326
327
328int
329glusterfs_graph_unknown_options (glusterfs_graph_t *graph)
330{
331 xlator_foreach (graph->first, _xlator_check_unknown_options, NULL((void*)0));
332 return 0;
333}
334
335
336void
337fill_uuid (char *uuid, int size)
338{
339 char hostname[256] = {0,};
340 struct timeval tv = {0,};
341 char now_str[64];
342
343 if (gettimeofday (&tv, NULL((void*)0)) == -1) {
344 gf_log ("graph", GF_LOG_ERROR,do { do { if (0) printf ("gettimeofday: failed %s", strerror (
(*__errno_location ()))); } while (0); _gf_log ("graph", "graph.c"
, __FUNCTION__, 346, GF_LOG_ERROR, "gettimeofday: failed %s",
strerror ((*__errno_location ()))); } while (0)
345 "gettimeofday: failed %s",do { do { if (0) printf ("gettimeofday: failed %s", strerror (
(*__errno_location ()))); } while (0); _gf_log ("graph", "graph.c"
, __FUNCTION__, 346, GF_LOG_ERROR, "gettimeofday: failed %s",
strerror ((*__errno_location ()))); } while (0)
346 strerror (errno))do { do { if (0) printf ("gettimeofday: failed %s", strerror (
(*__errno_location ()))); } while (0); _gf_log ("graph", "graph.c"
, __FUNCTION__, 346, GF_LOG_ERROR, "gettimeofday: failed %s",
strerror ((*__errno_location ()))); } while (0)
;
347 }
348
349 if (gethostname (hostname, 256) == -1) {
350 gf_log ("graph", GF_LOG_ERROR,do { do { if (0) printf ("gethostname: failed %s", strerror (
(*__errno_location ()))); } while (0); _gf_log ("graph", "graph.c"
, __FUNCTION__, 352, GF_LOG_ERROR, "gethostname: failed %s", strerror
((*__errno_location ()))); } while (0)
351 "gethostname: failed %s",do { do { if (0) printf ("gethostname: failed %s", strerror (
(*__errno_location ()))); } while (0); _gf_log ("graph", "graph.c"
, __FUNCTION__, 352, GF_LOG_ERROR, "gethostname: failed %s", strerror
((*__errno_location ()))); } while (0)
352 strerror (errno))do { do { if (0) printf ("gethostname: failed %s", strerror (
(*__errno_location ()))); } while (0); _gf_log ("graph", "graph.c"
, __FUNCTION__, 352, GF_LOG_ERROR, "gethostname: failed %s", strerror
((*__errno_location ()))); } while (0)
;
353 }
354
355 gf_time_fmt (now_str, sizeof now_str, tv.tv_sec, gf_timefmt_Ymd_T);
356 snprintf (uuid, size, "%s-%d-%s:%"GF_PRI_SUSECONDS"06ld",
357 hostname, getpid(), now_str, tv.tv_usec);
358
359 return;
360}
361
362
363int
364glusterfs_graph_settop (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
365{
366 const char *volume_name = NULL((void*)0);
367 xlator_t *trav = NULL((void*)0);
368
369 volume_name = ctx->cmd_args.volume_name;
370
371 if (!volume_name) {
372 graph->top = graph->first;
373 return 0;
374 }
375
376 for (trav = graph->first; trav; trav = trav->next) {
377 if (strcmp (trav->name, volume_name) == 0) {
378 graph->top = trav;
379 return 0;
380 }
381 }
382
383 return -1;
384}
385
386
387int
388glusterfs_graph_parent_up (glusterfs_graph_t *graph)
389{
390 xlator_t *trav = NULL((void*)0);
391 int ret = -1;
392
393 trav = graph->first;
394
395 while (trav) {
396 if (!xlator_has_parent (trav)(trav->parents != ((void*)0))) {
397 ret = xlator_notify (trav, GF_EVENT_PARENT_UP, trav);
398 }
399
400 if (ret)
401 break;
402
403 trav = trav->next;
404 }
405
406 return ret;
407}
408
409
410int
411glusterfs_graph_prepare (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
412{
413 xlator_t *trav = NULL((void*)0);
414 int ret = 0;
415
416 /* XXX: CHECKSUM */
417
418 /* XXX: attach to -n volname */
419 ret = glusterfs_graph_settop (graph, ctx);
420 if (ret) {
421 gf_log ("graph", GF_LOG_ERROR, "glusterfs graph settop failed")do { do { if (0) printf ("glusterfs graph settop failed"); } while
(0); _gf_log ("graph", "graph.c", __FUNCTION__, 421, GF_LOG_ERROR
, "glusterfs graph settop failed"); } while (0)
;
422 return -1;
423 }
424
425 /* XXX: WORM VOLUME */
426 ret = glusterfs_graph_worm (graph, ctx);
427 if (ret) {
428 gf_log ("graph", GF_LOG_ERROR, "glusterfs graph worm failed")do { do { if (0) printf ("glusterfs graph worm failed"); } while
(0); _gf_log ("graph", "graph.c", __FUNCTION__, 428, GF_LOG_ERROR
, "glusterfs graph worm failed"); } while (0)
;
429 return -1;
430 }
431 ret = glusterfs_graph_acl (graph, ctx);
432 if (ret) {
433 gf_log ("graph", GF_LOG_ERROR, "glusterfs graph ACL failed")do { do { if (0) printf ("glusterfs graph ACL failed"); } while
(0); _gf_log ("graph", "graph.c", __FUNCTION__, 433, GF_LOG_ERROR
, "glusterfs graph ACL failed"); } while (0)
;
434 return -1;
435 }
436
437 /* XXX: MAC COMPAT */
438 ret = glusterfs_graph_mac_compat (graph, ctx);
439 if (ret) {
440 gf_log ("graph", GF_LOG_ERROR, "glusterfs graph mac compat failed")do { do { if (0) printf ("glusterfs graph mac compat failed")
; } while (0); _gf_log ("graph", "graph.c", __FUNCTION__, 440
, GF_LOG_ERROR, "glusterfs graph mac compat failed"); } while
(0)
;
441 return -1;
442 }
443
444 /* XXX: this->ctx setting */
445 for (trav = graph->first; trav; trav = trav->next) {
446 trav->ctx = ctx;
447 }
448
449 /* XXX: DOB setting */
450 gettimeofday (&graph->dob, NULL((void*)0));
451
452 fill_uuid (graph->graph_uuid, 128);
453
454 graph->id = ctx->graph_id++;
455
456 /* XXX: --xlator-option additions */
457 gf_add_cmdline_options (graph, &ctx->cmd_args);
458
459
460 return 0;
461}
462
463
464int
465glusterfs_graph_activate (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
466{
467 int ret = 0;
468
469 /* XXX: all xlator options validation */
470 ret = glusterfs_graph_validate_options (graph);
471 if (ret) {
472 gf_log ("graph", GF_LOG_ERROR, "validate options failed")do { do { if (0) printf ("validate options failed"); } while (
0); _gf_log ("graph", "graph.c", __FUNCTION__, 472, GF_LOG_ERROR
, "validate options failed"); } while (0)
;
473 return ret;
474 }
475
476 /* XXX: perform init () */
477 ret = glusterfs_graph_init (graph);
478 if (ret) {
479 gf_log ("graph", GF_LOG_ERROR, "init failed")do { do { if (0) printf ("init failed"); } while (0); _gf_log
("graph", "graph.c", __FUNCTION__, 479, GF_LOG_ERROR, "init failed"
); } while (0)
;
480 return ret;
481 }
482
483 ret = glusterfs_graph_unknown_options (graph);
484 if (ret) {
485 gf_log ("graph", GF_LOG_ERROR, "unknown options failed")do { do { if (0) printf ("unknown options failed"); } while (
0); _gf_log ("graph", "graph.c", __FUNCTION__, 485, GF_LOG_ERROR
, "unknown options failed"); } while (0)
;
486 return ret;
487 }
488
489 /* XXX: log full graph (_gf_dump_details) */
490
491 list_add (&graph->list, &ctx->graphs);
492 ctx->active = graph;
493
494 /* XXX: attach to master and set active pointer */
495 if (ctx->master) {
496 ret = xlator_notify (ctx->master, GF_EVENT_GRAPH_NEW, graph);
497 if (ret) {
498 gf_log ("graph", GF_LOG_ERROR,do { do { if (0) printf ("graph new notification failed"); } while
(0); _gf_log ("graph", "graph.c", __FUNCTION__, 499, GF_LOG_ERROR
, "graph new notification failed"); } while (0)
499 "graph new notification failed")do { do { if (0) printf ("graph new notification failed"); } while
(0); _gf_log ("graph", "graph.c", __FUNCTION__, 499, GF_LOG_ERROR
, "graph new notification failed"); } while (0)
;
500 return ret;
501 }
502 ((xlator_t *)ctx->master)->next = graph->top;
503 }
504
505 /* XXX: perform parent up */
506 ret = glusterfs_graph_parent_up (graph);
507 if (ret) {
508 gf_log ("graph", GF_LOG_ERROR, "parent up notification failed")do { do { if (0) printf ("parent up notification failed"); } while
(0); _gf_log ("graph", "graph.c", __FUNCTION__, 508, GF_LOG_ERROR
, "parent up notification failed"); } while (0)
;
509 return ret;
510 }
511
512 return 0;
513}
514
515
516int
517glusterfs_graph_reconfigure (glusterfs_graph_t *oldgraph,
518 glusterfs_graph_t *newgraph)
519{
520 xlator_t *old_xl = NULL((void*)0);
521 xlator_t *new_xl = NULL((void*)0);
522
523 GF_ASSERT (oldgraph)do { if (!(oldgraph)) { do { do { if (0) printf ("Assertion failed: "
"oldgraph"); } while (0); _gf_log_callingfn ("", "graph.c", __FUNCTION__
, 523, GF_LOG_ERROR, "Assertion failed: " "oldgraph"); } while
(0); } } while (0)
;
524 GF_ASSERT (newgraph)do { if (!(newgraph)) { do { do { if (0) printf ("Assertion failed: "
"newgraph"); } while (0); _gf_log_callingfn ("", "graph.c", __FUNCTION__
, 524, GF_LOG_ERROR, "Assertion failed: " "newgraph"); } while
(0); } } while (0)
;
1
Within the expansion of the macro 'GF_ASSERT':
a
Assuming 'newgraph' is null
525
526 old_xl = oldgraph->first;
527 while (old_xl->is_autoloaded) {
2
Loop condition is false. Execution continues on line 531
528 old_xl = old_xl->children->xlator;
529 }
530
531 new_xl = newgraph->first;
3
Access to field 'first' results in a dereference of a null pointer (loaded from variable 'newgraph')
532 while (new_xl->is_autoloaded) {
533 new_xl = new_xl->children->xlator;
534 }
535
536 return xlator_tree_reconfigure (old_xl, new_xl);
537}
538
539int
540glusterfs_graph_destroy (glusterfs_graph_t *graph)
541{
542 return 0;
543}