From 92523f8cf2d58d3d2d0cf15706acdb8cba4c2af8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 29 Oct 2018 14:21:09 +0100 Subject: [PATCH] input/CdioParanoia: parse_cdio_uri() returns CdioUri The `bool` return value isn't used anymore, so we can just return the parsed object instead of passing it as an output parameter. --- src/input/plugins/CdioParanoiaInputPlugin.cxx | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/input/plugins/CdioParanoiaInputPlugin.cxx b/src/input/plugins/CdioParanoiaInputPlugin.cxx index d815eadc7..4cf5f6d19 100644 --- a/src/input/plugins/CdioParanoiaInputPlugin.cxx +++ b/src/input/plugins/CdioParanoiaInputPlugin.cxx @@ -127,43 +127,45 @@ struct CdioUri { int track; }; -static bool -parse_cdio_uri(CdioUri *dest, const char *src) +static CdioUri +parse_cdio_uri(const char *src) { + CdioUri dest; + if (*src == 0) { /* play the whole CD in the default drive */ - dest->device[0] = 0; - dest->track = -1; - return true; + dest.device[0] = 0; + dest.track = -1; + return dest; } const char *slash = strrchr(src, '/'); if (slash == nullptr) { /* play the whole CD in the specified drive */ - CopyTruncateString(dest->device, src, sizeof(dest->device)); - dest->track = -1; - return true; + CopyTruncateString(dest.device, src, sizeof(dest.device)); + dest.track = -1; + return dest; } size_t device_length = slash - src; - if (device_length >= sizeof(dest->device)) - device_length = sizeof(dest->device) - 1; + if (device_length >= sizeof(dest.device)) + device_length = sizeof(dest.device) - 1; - memcpy(dest->device, src, device_length); - dest->device[device_length] = 0; + memcpy(dest.device, src, device_length); + dest.device[device_length] = 0; const char *track = slash + 1; char *endptr; - dest->track = strtoul(track, &endptr, 10); + dest.track = strtoul(track, &endptr, 10); if (*endptr != 0) throw std::runtime_error("Malformed track number"); if (endptr == track) /* play the whole CD */ - dest->track = -1; + dest.track = -1; - return true; + return dest; } static AllocatedPath @@ -186,9 +188,7 @@ input_cdio_open(const char *uri, uri = StringAfterPrefixIgnoreCase(uri, "cdda://"); assert(uri != nullptr); - CdioUri parsed_uri; - if (!parse_cdio_uri(&parsed_uri, uri)) - return nullptr; + const auto parsed_uri = parse_cdio_uri(uri); /* get list of CD's supporting CD-DA */ const AllocatedPath device = parsed_uri.device[0] != 0