aboutsummaryrefslogtreecommitdiff
path: root/lib/libufs/type.c
diff options
context:
space:
mode:
authorJuli Mallett <jmallett@FreeBSD.org>2003-01-18 04:22:14 +0000
committerJuli Mallett <jmallett@FreeBSD.org>2003-01-18 04:22:14 +0000
commit49b2a6863b5cda7f53e18baa1747bfd5efdb2051 (patch)
tree42776587cf0e4fc2638f7d27ea614b94fbea2925 /lib/libufs/type.c
parentcbd866f41115cb0a99779db31463cd6c73cf3228 (diff)
downloadsrc-49b2a6863b5cda7f53e18baa1747bfd5efdb2051.tar.gz
src-49b2a6863b5cda7f53e18baa1747bfd5efdb2051.zip
Nuke dumb error reporting code, people can just use disk::d_error. Unify the
DEBUG and d_error initialisation into an ERROR macro, which can both trace and set the d_error field. Much a more meaningful thing, I should say.
Notes
Notes: svn path=/head/; revision=109462
Diffstat (limited to 'lib/libufs/type.c')
-rw-r--r--lib/libufs/type.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/lib/libufs/type.c b/lib/libufs/type.c
index 8bc30bd34200..622cba8577d7 100644
--- a/lib/libufs/type.c
+++ b/lib/libufs/type.c
@@ -51,16 +51,18 @@ ufs_disk_ctor(const char *name)
{
struct uufsd *new;
- DEBUG(NULL);
+ new = NULL;
+
+ ERROR(new, NULL);
new = malloc(sizeof(*new));
if (new == NULL) {
- DEBUG(NULL);
+ ERROR(new, "unable to allocate memory for disk");
return NULL;
}
if (ufs_disk_fillout(new, name) == -1) {
- DEBUG(NULL);
+ ERROR(new, "could not fill out disk");
free(new);
return NULL;
}
@@ -69,18 +71,26 @@ ufs_disk_ctor(const char *name)
}
void
-ufs_disk_dtor(struct uufsd **disk)
+ufs_disk_dtor(struct uufsd **diskp)
{
- DEBUG(NULL);
- ufs_disk_close(*disk);
- free(*disk);
- *disk = NULL;
+ struct uufsd *disk;
+
+ if (diskp != NULL)
+ disk = *diskp;
+ else
+ return;
+
+ ERROR(disk, NULL);
+
+ ufs_disk_close(disk);
+ free(disk);
+ *diskp = NULL;
}
int
ufs_disk_close(struct uufsd *disk)
{
- DEBUG(NULL);
+ ERROR(disk, NULL);
close(disk->d_fd);
if (disk->d_inoblock != NULL) {
free(disk->d_inoblock);
@@ -94,12 +104,11 @@ ufs_disk_fillout(struct uufsd *disk, const char *name)
{
int fd;
- DEBUG(NULL);
+ ERROR(disk, NULL);
fd = open(name, O_RDONLY);
if (fd == -1) {
- DEBUG("open");
- disk->d_error = "failed to open disk for reading";
+ ERROR(disk, "failed to open disk for reading");
return -1;
}
@@ -113,7 +122,7 @@ ufs_disk_fillout(struct uufsd *disk, const char *name)
disk->d_error = NULL;
if (sbread(disk) == -1) {
- DEBUG(NULL);
+ ERROR(disk, "could not read superblock to fill out disk");
return -1;
}