]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: consolidate duplicated error messages in pci.c
authorLaine Stump <laine@laine.org>
Thu, 8 Mar 2012 20:41:53 +0000 (15:41 -0500)
committerLaine Stump <laine@laine.org>
Thu, 8 Mar 2012 21:59:29 +0000 (16:59 -0500)
This is nearly identical to an earlier patch for virnetlink.c.

There are special stub versions of all public functions in this file
that are compiled when the platform isn't linux. Each of these
functions had an almost identical message, differing only in the
function name included in the message. Since log messages already
contain the function name, we can just define a const char* with the
common part of the string, and use that same string for all the log
messages.

If nothing else, this at least makes for less strings that need
translating...

src/util/pci.c

index e7bfb920e20b31007290eb247082853b2211cfc1..7beeaee6b1e57c44f204454b9c928df816f0b549 100644 (file)
@@ -2170,12 +2170,13 @@ cleanup:
 }
 
 #else
+static const char *unsupported = N_("not supported on non-linux platforms");
+
 int
 pciGetPhysicalFunction(const char *vf_sysfs_path ATTRIBUTE_UNUSED,
               struct pci_config_address **physical_function ATTRIBUTE_UNUSED)
 {
-    pciReportError(VIR_ERR_INTERNAL_ERROR, _("pciGetPhysicalFunction is not "
-                   "supported on non-linux platforms"));
+    pciReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
     return -1;
 }
 
@@ -2184,16 +2185,14 @@ pciGetVirtualFunctions(const char *sysfs_path ATTRIBUTE_UNUSED,
              struct pci_config_address ***virtual_functions ATTRIBUTE_UNUSED,
              unsigned int *num_virtual_functions ATTRIBUTE_UNUSED)
 {
-    pciReportError(VIR_ERR_INTERNAL_ERROR, _("pciGetVirtualFunctions is not "
-                   "supported on non-linux platforms"));
+    pciReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
     return -1;
 }
 
 int
 pciDeviceIsVirtualFunction(const char *vf_sysfs_device_link ATTRIBUTE_UNUSED)
 {
-    pciReportError(VIR_ERR_INTERNAL_ERROR, _("pciDeviceIsVirtualFunction is "
-                   "not supported on non-linux platforms"));
+    pciReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
     return -1;
 }
 
@@ -2202,8 +2201,7 @@ pciGetVirtualFunctionIndex(const char *pf_sysfs_device_link ATTRIBUTE_UNUSED,
                            const char *vf_sysfs_device_link ATTRIBUTE_UNUSED,
                            int *vf_index ATTRIBUTE_UNUSED)
 {
-    pciReportError(VIR_ERR_INTERNAL_ERROR, _("pciGetVirtualFunctionIndex is "
-                   "not supported on non-linux platforms"));
+    pciReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
     return -1;
 
 }
@@ -2212,8 +2210,7 @@ int
 pciConfigAddressToSysfsFile(struct pci_config_address *dev ATTRIBUTE_UNUSED,
                             char **pci_sysfs_device_link ATTRIBUTE_UNUSED)
 {
-    pciReportError(VIR_ERR_INTERNAL_ERROR, _("pciConfigAddressToSysfsFile is not "
-                   "supported on non-linux platforms"));
+    pciReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
     return -1;
 }
 
@@ -2221,8 +2218,7 @@ int
 pciDeviceNetName(char *device_link_sysfs_path ATTRIBUTE_UNUSED,
                  char **netname ATTRIBUTE_UNUSED)
 {
-    pciReportError(VIR_ERR_INTERNAL_ERROR, _("pciDeviceNetName is not "
-                   "supported on non-linux platforms"));
+    pciReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
     return -1;
 }
 
@@ -2231,8 +2227,7 @@ pciDeviceGetVirtualFunctionInfo(const char *vf_sysfs_device_path ATTRIBUTE_UNUSE
                                 char **pfname ATTRIBUTE_UNUSED,
                                 int *vf_index ATTRIBUTE_UNUSED)
 {
-    pciReportError(VIR_ERR_INTERNAL_ERROR, _("pciDeviceGetVirtualFunctionInfo "
-                   "is not supported on non-linux platforms"));
+    pciReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
     return -1;
 }
 #endif /* __linux__ */