diff options
| author | skidau <skidau@gmail.com> | 2014-10-24 13:03:09 +1100 |
|---|---|---|
| committer | skidau <skidau@gmail.com> | 2014-10-24 13:03:09 +1100 |
| commit | 716fe06289eb73a25e5d40d4a1be029d75337f98 (patch) | |
| tree | f2df6ca999c6fe3f39a6ede69d25950d71593001 /Source/Core/Common/CDUtils.cpp | |
| parent | ace57fb51524f47752da12b1f3476b6c5cc89ec5 (diff) | |
| parent | 06433652bead1e902539d01712591a0aca5eb392 (diff) | |
Merge pull request #1349 from comex/good-job-dereferencing-null-on-purpose
Fix some warnings from Clang trunk in an overly aggressive manner
Diffstat (limited to 'Source/Core/Common/CDUtils.cpp')
| -rw-r--r-- | Source/Core/Common/CDUtils.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/Source/Core/Common/CDUtils.cpp b/Source/Core/Common/CDUtils.cpp index 45f2011149..50c1902eac 100644 --- a/Source/Core/Common/CDUtils.cpp +++ b/Source/Core/Common/CDUtils.cpp @@ -91,8 +91,6 @@ std::vector<std::string> cdio_get_devices() next_media = IOIteratorNext( media_iterator ); if (next_media != 0) { - char psz_buf[0x32]; - size_t dev_path_length; CFTypeRef str_bsd_path; do @@ -107,22 +105,20 @@ std::vector<std::string> cdio_get_devices() continue; } - // Below, by appending 'r' to the BSD node name, we indicate - // a raw disk. Raw disks receive I/O requests directly and - // don't go through a buffer cache. - snprintf( psz_buf, sizeof(psz_buf), "%s%c", _PATH_DEV, 'r' ); - dev_path_length = strlen( psz_buf ); - - if (CFStringGetCString( (CFStringRef)str_bsd_path, - (char*)&psz_buf + dev_path_length, - sizeof(psz_buf) - dev_path_length, - kCFStringEncodingASCII)) + if (CFGetTypeID(str_bsd_path) == CFStringGetTypeID()) { - if (psz_buf != nullptr) + size_t buf_size = CFStringGetLength((CFStringRef)str_bsd_path) * 4 + 1; + char* buf = new char[buf_size]; + + if (CFStringGetCString((CFStringRef)str_bsd_path, buf, buf_size, kCFStringEncodingUTF8)) { - std::string str = psz_buf; - drives.push_back(str); + // Below, by appending 'r' to the BSD node name, we indicate + // a raw disk. Raw disks receive I/O requests directly and + // don't go through a buffer cache. + drives.push_back(std::string(_PATH_DEV "r") + buf); } + + delete[] buf; } CFRelease( str_bsd_path ); IOObjectRelease( next_media ); |
