Bug Summary

File:obj-scan-build/libcons/../../libcons/dir-changed.c
Location:line 107, column 6
Description:Function call argument is an uninitialized value

Annotated Source Code

1/* dir-changed.c - Handling dir changed notifications.
2 Copyright (C) 2002 Free Software Foundation, Inc.
3 Written by Marcus Brinkmann.
4
5 This file is part of the GNU Hurd.
6
7 The GNU Hurd is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2, or (at
10 your option) any later version.
11
12 The GNU Hurd is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
20
21#include <errno(*__errno_location ()).h>
22#include <dirent.h>
23#include <assert.h>
24#include <mach.h>
25#include <pthread.h>
26
27#include "cons.h"
28#include "fs_notify_S.h"
29
30
31static error_t
32add_one (cons_t cons, char *name)
33{
34 unsigned long int nr;
35 char *tail;
36
37 errno(*__errno_location ()) = 0;
38 nr = strtoul (name, &tail, 10);
39 if (!errno(*__errno_location ()) && *tail == '\0' && nr > 0)
40 {
41 vcons_list_t vcons_entry;
42 return cons_lookup (cons, nr, 1, &vcons_entry);
43 }
44 return 0;
45}
46
47static error_t
48lookup_one (cons_t cons, char *name, vcons_list_t *vcons_entry)
49{
50 unsigned long int nr;
51 char *tail;
52
53 errno(*__errno_location ()) = 0;
54 nr = strtoul (name, &tail, 10);
55 if (!errno(*__errno_location ()) && *tail == '\0' && nr > 0)
56 return cons_lookup (cons, nr, 0, vcons_entry);
57 return 0;
58}
59
60
61kern_return_t
62cons_S_dir_changed (cons_notify_t notify, natural_t tickno,
63 dir_changed_type_t change, string_t name)
64{
65 error_t err;
66 cons_t cons;
67
68 if (!notify || !notify->cons)
1
Assuming 'notify' is non-null
2
Taking false branch
69 return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff));
70 cons = notify->cons;
71
72 pthread_mutex_lock (&cons->lock);
73
74 switch (change)
3
Control jumps to 'case DIR_CHANGED_UNLINK:' at line 101
75 {
76 case DIR_CHANGED_NULL:
77 {
78 DIR *dir = cons->dir;
79 struct dirent *dent;
80 do
81 {
82 errno(*__errno_location ()) = 0;
83 dent = readdir (dir);
84 if (!dent && errno(*__errno_location ()))
85 err = errno(*__errno_location ());
86 else if (dent)
87 err = add_one (cons, dent->d_name);
88 }
89 while (dent && !err);
90 if (err)
91 assert ("Unexpected error")(("Unexpected error") ? (void) (0) : __assert_fail ("\"Unexpected error\""
, "../../libcons/dir-changed.c", 91, __PRETTY_FUNCTION__))
; /* XXX */
92 }
93 break;
94 case DIR_CHANGED_NEW:
95 {
96 err = add_one (cons, name);
97 if (err)
98 assert ("Unexpected error")(("Unexpected error") ? (void) (0) : __assert_fail ("\"Unexpected error\""
, "../../libcons/dir-changed.c", 98, __PRETTY_FUNCTION__))
; /* XXX */
99 }
100 break;
101 case DIR_CHANGED_UNLINK:
102 {
103 vcons_list_t vcons_entry;
4
Variable 'vcons_entry' declared without an initial value
104 err = lookup_one (cons, name, &vcons_entry);
5
Calling 'lookup_one'
6
Returning from 'lookup_one'
105 if (!err)
7
Taking true branch
106 {
107 cons_vcons_remove (cons, vcons_entry);
8
Function call argument is an uninitialized value
108 if (vcons_entry->prev)
109 vcons_entry->prev->next = vcons_entry->next;
110 else
111 cons->vcons_list = vcons_entry->next;
112 if (vcons_entry->next)
113 vcons_entry->next->prev = vcons_entry->prev;
114 else
115 cons->vcons_last = vcons_entry->prev;
116
117 free (vcons_entry);
118 }
119 }
120 break;
121 case DIR_CHANGED_RENUMBER:
122 default:
123 assert ("Unexpected dir-changed type.")(("Unexpected dir-changed type.") ? (void) (0) : __assert_fail
("\"Unexpected dir-changed type.\"", "../../libcons/dir-changed.c"
, 123, __PRETTY_FUNCTION__))
;
124 pthread_mutex_unlock (&cons->lock);
125 return EINVAL((0x10 << 26) | ((22) & 0x3fff));
126 }
127 pthread_mutex_unlock (&cons->lock);
128 return 0;
129}