From 6070a3461841d4398d731fcb33792d55779111f1 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 16 Apr 2011 01:10:09 +0200 Subject: fix a bunch of cppcheck warnings/errors based on a patch by Niels Thykier, thanks! (Closes: #622805) --- apt-pkg/contrib/cdromutl.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'apt-pkg/contrib/cdromutl.cc') diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 83c324f54..821e6d688 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -206,8 +205,11 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version) Hash.Add(Dir->d_name); }; - if (chdir(StartDir.c_str()) != 0) - return _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str()); + if (chdir(StartDir.c_str()) != 0) { + _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str()); + closedir(D); + return false; + } closedir(D); // Some stats from the fsys @@ -236,7 +238,7 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version) } /*}}}*/ -// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/ +// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/ string FindMountPointForDevice(const char *devnode) { char buf[255]; @@ -254,7 +256,10 @@ string FindMountPointForDevice(const char *devnode) while ( fgets(buf, sizeof(buf), f) != NULL) { if (strncmp(buf, devnode, strlen(devnode)) == 0) { if(TokSplitString(' ', buf, out, 10)) + { + fclose(f); return string(out[1]); + } } } fclose(f); @@ -263,5 +268,4 @@ string FindMountPointForDevice(const char *devnode) return string(); } - - + /*}}}*/ -- cgit v1.2.3