Bug Summary

File:obj-scan-build/fstests/../../fstests/fstests.c
Location:line 92, column 3
Description:Call to 'malloc' has an allocation size of 0 bytes

Annotated Source Code

1/* Test filesystem behavior
2 Copyright (C) 1993,94,2000,01,02 Free Software Foundation, Inc.
3
4This file is part of the GNU Hurd.
5
6The GNU Hurd is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11The GNU Hurd is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with the GNU Hurd; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20/* Written by Michael I. Bushnell. */
21
22#include <mach.h>
23#include <stdio.h>
24#include <hurd/hurd_types.h>
25#include <hurd/fs.h>
26#include <hurd/io.h>
27#include <hurd.h>
28#include <fcntl.h>
29#include <errno(*__errno_location ()).h>
30#include <error.h>
31#include <unistd.h>
32
33int check_refs (mach_port_t port) /* To call from gdb */
34{
35 int err;
36 mach_port_urefs_t refs;
37 err = mach_port_get_refs (mach_task_self ()((__mach_task_self_ + 0)),
38 port, MACH_PORT_RIGHT_SEND((mach_port_right_t) 0), &refs);
39 return err ? -err : refs;
40}
41
42int
43main ()
44{
45 mach_port_t root;
46#if HURDISH_TESTS
47 extern file_t *_hurd_init_dtable;
48 char string[] = "Did this get into the file?\n";
49 file_t filetowrite;
50 retry_type retry;
51 char pathbuf[1024];
52 int written;
53 error_t err;
54#endif
55
56 root = getcrdir ();
57
58 printf ("fstests running...\n");
59
60#if HURDISH_TESTS
61 if ((err = dir_unlink (root, "CREATED")) && err != ENOENT((0x10 << 26) | ((2) & 0x3fff)))
62 error (0, err, "Error on unlink");
63 else if (err = dir_lookup (root, "CREATED", O_WRITE0x0002 | O_CREAT0x0010, 0666,
64 &retry, pathbuf, &filetowrite))
65 error (0, err, "Error on lookup");
66 else if (err = io_write (filetowrite, string, strlen (string), -1, &written))
67 error (0, err, "Error on write");
68 else if (written != strlen (string))
69 error (0, 0, "Short write: %d\n", written);
70 else if (err = file_syncfs (filetowrite, 1, 0))
71 error (0, err, "Error on sync");
72#else
73
74 if (unlink ("/newdir"))
1
Taking false branch
75 error (0, errno(*__errno_location ()), "unlink");
76 if (rmdir ("/newdir"))
2
Taking false branch
77 error (0, errno(*__errno_location ()), "1st rmdir");
78 if (mkdir ("/newdir", 0777))
3
Taking false branch
79 error (0, errno(*__errno_location ()), "1st mkdir");
80 if (rename ("/newdir", "/newdir2"))
4
Taking false branch
81 error (0, errno(*__errno_location ()), "1st rename");
82 if (rmdir ("/foo"))
5
Taking false branch
83 error (0, errno(*__errno_location ()), "2nd rmdir");
84 if (mkdir ("/foo", 0777))
6
Taking false branch
85 error (0, errno(*__errno_location ()), "2nd mkdir");
86 if (rename ("/newdir2", "/foo"))
7
Taking false branch
87 error (0, errno(*__errno_location ()), "2nd rename");
88 sync ();
89#endif
90
91 printf ("All done.\n");
92 malloc (0);
8
Call to 'malloc' has an allocation size of 0 bytes
93
94 return 0;
95}