Fix clazy warnings regarding range-for references
[pulseview.git] / pv / devices / hardwaredevice.cpp
index 318ce1cab26fa61330563fbdd075a5ab510193be..a3d84d6fadf175973fab3a2a420f190838948fc2 100644 (file)
@@ -14,8 +14,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <boost/algorithm/string/join.hpp>
@@ -28,7 +27,6 @@
 
 #include "hardwaredevice.hpp"
 
-using std::dynamic_pointer_cast;
 using std::shared_ptr;
 using std::static_pointer_cast;
 using std::string;
@@ -41,8 +39,8 @@ using sigrok::HardwareDevice;
 namespace pv {
 namespace devices {
 
-HardwareDevice::HardwareDevice(const std::shared_ptr<sigrok::Context> &context,
-       std::shared_ptr<sigrok::HardwareDevice> device) :
+HardwareDevice::HardwareDevice(const shared_ptr<sigrok::Context> &context,
+       shared_ptr<sigrok::HardwareDevice> device) :
        context_(context),
        device_open_(false)
 {
@@ -56,8 +54,15 @@ HardwareDevice::~HardwareDevice()
 
 string HardwareDevice::full_name() const
 {
-       vector<string> parts = {device_->vendor(), device_->model(),
-               device_->version(), device_->serial_number()};
+       vector<string> parts = {};
+       if (device_->vendor().length() > 0)
+               parts.push_back(device_->vendor());
+       if (device_->model().length() > 0)
+               parts.push_back(device_->model());
+       if (device_->version().length() > 0)
+               parts.push_back(device_->version());
+       if (device_->serial_number().length() > 0)
+               parts.push_back("[S/N: " + device_->serial_number() + "]");
        if (device_->connection_id().length() > 0)
                parts.push_back("(" + device_->connection_id() + ")");
        return join(parts, " ");
@@ -86,11 +91,17 @@ string HardwareDevice::display_name(
                                dev->device_ != device_;
                });
 
-       vector<string> parts = {device_->vendor(), device_->model()};
+       vector<string> parts = {};
+       if (device_->vendor().length() > 0)
+               parts.push_back(device_->vendor());
+       if (device_->model().length() > 0)
+               parts.push_back(device_->model());
 
        if (multiple_dev) {
-               parts.push_back(device_->version());
-               parts.push_back(device_->serial_number());
+               if (device_->version().length() > 0)
+                       parts.push_back(device_->version());
+               if (device_->serial_number().length() > 0)
+                       parts.push_back("[S/N: " + device_->serial_number() + "]");
 
                if ((device_->serial_number().length() == 0) &&
                        (device_->connection_id().length() > 0))