Use G_GNUC_FALLTHROUGH instead of ATTRIBUTE_FALLTHROUGH

Also define the macro for building with GLib older than 2.60

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Ján Tomko 2019-10-15 13:38:21 +02:00
parent dd3738acc4
commit 88131931b8
26 changed files with 56 additions and 55 deletions

View File

@ -629,7 +629,7 @@ sc_avoid_g_gnuc_unused_in_header:
$(_sc_search_regexp)
sc_prohibit_attribute_macros:
@prohibit='ATTRIBUTE_(UNUSED|NORETURN|SENTINEL|RETURN_CHECK|NOINLINE|FMT_PRINTF)' \
@prohibit='ATTRIBUTE_(UNUSED|NORETURN|SENTINEL|RETURN_CHECK|NOINLINE|FMT_PRINTF|FALLTHROUGH)' \
in_vc_files='\.[ch]$$' \
halt='use GLib macros: G_GNUC_<ATTRIBUTE_SUFFIX> for most' \
$(_sc_search_regexp)

View File

@ -17486,7 +17486,7 @@ virDomainChrEquals(virDomainChrDefPtr src,
if (src->targetType != tgt->targetType)
return false;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
@ -20290,7 +20290,7 @@ virDomainDefParseXML(xmlDocPtr xml,
def->apic_eoi = eoi;
VIR_FREE(tmp);
}
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_DOMAIN_FEATURE_ACPI:
case VIR_DOMAIN_FEATURE_PAE:
case VIR_DOMAIN_FEATURE_VIRIDIAN:
@ -31205,7 +31205,7 @@ virDomainNetResolveActualType(virDomainNetDefPtr iface)
/* intentionally fall through to the direct case for
* VIR_NETWORK_FORWARD_BRIDGE with no bridge device defined
*/
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_NETWORK_FORWARD_PRIVATE:
case VIR_NETWORK_FORWARD_VEPA:
@ -31471,7 +31471,7 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def)
case VIR_STORAGE_SOURCE_POOL_MODE_DEFAULT:
case VIR_STORAGE_SOURCE_POOL_MODE_LAST:
def->src->srcpool->mode = VIR_STORAGE_SOURCE_POOL_MODE_HOST;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_STORAGE_SOURCE_POOL_MODE_HOST:
def->src->srcpool->actualtype = VIR_STORAGE_TYPE_BLOCK;
if (!(def->src->path = virStorageVolGetPath(vol)))

View File

@ -1984,7 +1984,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
def->name);
goto error;
}
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_NETWORK_FORWARD_BRIDGE:
if (def->delay || stp || def->bridgeZone) {

View File

@ -1863,7 +1863,7 @@ virNWFilterRuleDetailsParse(xmlNodePtr node,
switch (datatype) {
case DATATYPE_UINT8_HEX:
base = 16;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case DATATYPE_UINT8:
if (virStrToLong_ui(prop, NULL, base, &uint_val) >= 0) {
if (uint_val <= 0xff) {
@ -1880,7 +1880,7 @@ virNWFilterRuleDetailsParse(xmlNodePtr node,
case DATATYPE_UINT16_HEX:
base = 16;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case DATATYPE_UINT16:
if (virStrToLong_ui(prop, NULL, base, &uint_val) >= 0) {
if (uint_val <= 0xffff) {
@ -1897,7 +1897,7 @@ virNWFilterRuleDetailsParse(xmlNodePtr node,
case DATATYPE_UINT32_HEX:
base = 16;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case DATATYPE_UINT32:
if (virStrToLong_ui(prop, NULL, base, &uint_val) >= 0) {
item->u.u32 = uint_val;
@ -2131,7 +2131,7 @@ virNWFilterRuleValidate(virNWFilterRuleDefPtr rule)
portData = &rule->p.ipHdrFilter.portData;
protocol = "IP";
dataProtocolID = &rule->p.ipHdrFilter.ipHdr.dataProtocolID;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_NWFILTER_RULE_PROTOCOL_IPV6:
if (portData == NULL) {
portData = &rule->p.ipv6HdrFilter.portData;
@ -2926,7 +2926,7 @@ virNWFilterRuleDefDetailsFormat(virBufferPtr buf,
case DATATYPE_UINT8_HEX:
asHex = true;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case DATATYPE_IPMASK:
case DATATYPE_IPV6MASK:
/* display all masks in CIDR format */
@ -2937,7 +2937,7 @@ virNWFilterRuleDefDetailsFormat(virBufferPtr buf,
case DATATYPE_UINT16_HEX:
asHex = true;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case DATATYPE_UINT16:
virBufferAsprintf(buf, asHex ? "0x%x" : "%d",
item->u.u16);
@ -2945,7 +2945,7 @@ virNWFilterRuleDefDetailsFormat(virBufferPtr buf,
case DATATYPE_UINT32_HEX:
asHex = true;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case DATATYPE_UINT32:
virBufferAsprintf(buf, asHex ? "0x%x" : "%u",
item->u.u32);

View File

@ -510,7 +510,7 @@ ppc64Compute(virCPUDefPtr host,
ret = tmp;
goto cleanup;
}
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_CPU_MODE_HOST_PASSTHROUGH:
/* host-model and host-passthrough:

View File

@ -137,16 +137,17 @@
/**
*
* ATTRIBUTE_FALLTHROUGH
* G_GNUC_FALLTHROUGH
*
* silence the compiler warning when falling through a switch case
*
* TODO: Remove after upgrading to GLib >= 2.60
*/
#ifndef ATTRIBUTE_FALLTHROUGH
#ifndef G_GNUC_FALLTHROUGH
# if __GNUC_PREREQ (7, 0)
# define ATTRIBUTE_FALLTHROUGH __attribute__((fallthrough))
# define G_GNUC_FALLTHROUGH __attribute__((fallthrough))
# else
# define ATTRIBUTE_FALLTHROUGH do {} while(0)
# define G_GNUC_FALLTHROUGH do {} while(0)
# endif
#endif

View File

@ -8037,7 +8037,7 @@ virDomainSetMetadata(virDomainPtr domain,
"newlines"));
goto error;
}
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_DOMAIN_METADATA_DESCRIPTION:
virCheckNullArgGoto(uri, error);
virCheckNullArgGoto(key, error);

View File

@ -1346,7 +1346,7 @@ libxlMakeNic(virDomainDefPtr def,
if (VIR_STRDUP(x_nic->bridge,
virBufferCurrentContent(&buf)) < 0)
goto cleanup;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_DOMAIN_NET_TYPE_ETHERNET:
if (VIR_STRDUP(x_nic->script, script) < 0)
goto cleanup;

View File

@ -2044,7 +2044,7 @@ static int lxcContainerDropCapabilities(virDomainDefPtr def,
default: /* User specified capabilities to drop */
toDrop = (state == VIR_TRISTATE_SWITCH_OFF);
}
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_DOMAIN_CAPABILITIES_POLICY_ALLOW:
if (policy == VIR_DOMAIN_CAPABILITIES_POLICY_ALLOW)

View File

@ -2961,7 +2961,7 @@ networkStartNetwork(virNetworkDriverStatePtr driver,
* VIR_NETWORK_FORWARD_BRIDGE with no bridge device defined
* (since that is macvtap bridge mode).
*/
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_NETWORK_FORWARD_PRIVATE:
case VIR_NETWORK_FORWARD_VEPA:
@ -3048,7 +3048,7 @@ networkShutdownNetwork(virNetworkDriverStatePtr driver,
* VIR_NETWORK_FORWARD_BRIDGE with no bridge device defined
* (since that is macvtap bridge mode).
*/
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_NETWORK_FORWARD_PRIVATE:
case VIR_NETWORK_FORWARD_VEPA:
@ -3433,7 +3433,7 @@ networkValidate(virNetworkDriverStatePtr driver,
if (def->bridge != NULL)
bandwidthAllowed = true;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_NETWORK_FORWARD_PRIVATE:
case VIR_NETWORK_FORWARD_VEPA:
@ -4710,7 +4710,7 @@ networkAllocatePort(virNetworkObjPtr obj,
/* intentionally fall through to the direct case for
* VIR_NETWORK_FORWARD_BRIDGE with no bridge device defined
*/
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_NETWORK_FORWARD_PRIVATE:
case VIR_NETWORK_FORWARD_VEPA:

View File

@ -193,7 +193,7 @@ main(int argc, char **argv)
if (!lease_new)
break;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_LEASE_ACTION_DEL:
/* Delete the corresponding lease, if it already exists */
delete = true;
@ -230,7 +230,7 @@ main(int argc, char **argv)
}
lease_new = NULL;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_LEASE_ACTION_DEL:
if (!(leases_str = virJSONValueToString(leases_array_new, true))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",

View File

@ -7254,7 +7254,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
* early instead of erroring out */
break;
}
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_GIC_VERSION_3:
case VIR_GIC_VERSION_HOST:
@ -9053,7 +9053,7 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
virCommandAddArg(cmd, "-object");
virCommandAddArgBuffer(cmd, &buf);
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL:
devstr = qemuBuildShmemDevStr(def, shmem, qemuCaps);
break;

View File

@ -209,7 +209,7 @@ qemuDomainAsyncJobPhaseToString(qemuDomainAsyncJob job,
case QEMU_ASYNC_JOB_SNAPSHOT:
case QEMU_ASYNC_JOB_START:
case QEMU_ASYNC_JOB_NONE:
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case QEMU_ASYNC_JOB_LAST:
break;
}
@ -234,7 +234,7 @@ qemuDomainAsyncJobPhaseFromString(qemuDomainAsyncJob job,
case QEMU_ASYNC_JOB_SNAPSHOT:
case QEMU_ASYNC_JOB_START:
case QEMU_ASYNC_JOB_NONE:
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case QEMU_ASYNC_JOB_LAST:
break;
}
@ -3102,7 +3102,7 @@ qemuDomainObjPrivateXMLParseBlockjobDataSpecific(qemuBlockJobDataPtr job,
if (!job->data.commit.topparent)
goto broken;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT:
qemuDomainObjPrivateXMLParseBlockjobNodename(job,
"string(./top/@node)",

View File

@ -4324,7 +4324,7 @@ processGuestPanicEvent(virQEMUDriverPtr driver,
case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY:
if (doCoreDumpToAutoDumpPath(driver, vm, flags) < 0)
goto endjob;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY:
qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED,
@ -4341,7 +4341,7 @@ processGuestPanicEvent(virQEMUDriverPtr driver,
case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART:
if (doCoreDumpToAutoDumpPath(driver, vm, flags) < 0)
goto endjob;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART:
qemuDomainSetFakeReboot(driver, vm, true);

View File

@ -2957,7 +2957,7 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("live attach of shmem model '%s' is not supported"),
virDomainShmemModelTypeToString(shmem->model));
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_DOMAIN_SHMEM_MODEL_LAST:
return -1;
}
@ -5454,7 +5454,7 @@ qemuDomainDetachPrepShmem(virDomainObjPtr vm,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("live detach of shmem model '%s' is not supported"),
virDomainShmemModelTypeToString(shmem->model));
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_DOMAIN_SHMEM_MODEL_LAST:
return -1;
}

View File

@ -582,7 +582,7 @@ qemuMigrationSrcNBDCopyCancelled(virDomainObjPtr vm,
qemuMigrationNBDReportMirrorError(job, disk->dst);
failed = true;
}
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_DOMAIN_BLOCK_JOB_CANCELED:
case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
diskPriv->migrating = false;
@ -656,7 +656,7 @@ qemuMigrationSrcNBDCopyCancelOne(virQEMUDriverPtr driver,
qemuMigrationNBDReportMirrorError(job, disk->dst);
goto cleanup;
}
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
ret = 1;
goto cleanup;

View File

@ -4811,7 +4811,7 @@ qemuProcessGetNetworkAddress(const char *netname,
* fall through if netdef->bridge wasn't set, since that is
* macvtap bridge mode network.
*/
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_NETWORK_FORWARD_PRIVATE:
case VIR_NETWORK_FORWARD_VEPA:

View File

@ -1159,7 +1159,7 @@ doRemoteOpen(virConnectPtr conn,
if (!priv->tls)
goto failed;
priv->is_secure = 1;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
#else
(void)tls_priority;
(void)sanity;

View File

@ -984,7 +984,7 @@ int virConfGetValueStringList(virConfPtr conf,
}
break;
}
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_CONF_LLONG:
case VIR_CONF_ULLONG:

View File

@ -101,17 +101,17 @@ uint32_t virHashCodeGen(const void *key, size_t len, uint32_t seed)
switch (len & 3) {
case 3:
k1 ^= tail[2] << 16;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case 2:
k1 ^= tail[1] << 8;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case 1:
k1 ^= tail[0];
k1 *= c1;
k1 = rotl32(k1, 15);
k1 *= c2;
h1 ^= k1;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
default:
break;
}

View File

@ -487,7 +487,7 @@ virISCSIScanTargets(const char *portal,
virReportError(VIR_ERR_OPERATION_FAILED,
_("no iSCSI interface defined for IQN %s"),
initiatoriqn);
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case IQN_ERROR:
default:
return -1;

View File

@ -212,19 +212,19 @@ virScaleInteger(unsigned long long *value, const char *suffix,
switch (c_tolower(*suffix)) {
case 'e':
scale *= base;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case 'p':
scale *= base;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case 't':
scale *= base;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case 'g':
scale *= base;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case 'm':
scale *= base;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case 'k':
scale *= base;
break;

View File

@ -2596,14 +2596,14 @@ virshBlockJobInfo(vshControl *ctl,
switch (last_error->code) {
case VIR_ERR_INVALID_ARG:
priv->blockJobNoBytes = true;
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case VIR_ERR_OVERFLOW:
if (!bytes && !raw) {
/* try again with MiB/s, unless forcing bytes */
vshResetLibvirtError();
break;
}
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
default:
goto cleanup;
}

View File

@ -137,7 +137,7 @@ do {
relax_avail = false;
goto redefine;
}
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
#endif
default:

View File

@ -762,7 +762,7 @@ virshParseArgv(vshControl *ctl, int argc, char **argv)
puts(VERSION);
exit(EXIT_SUCCESS);
}
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case 'V':
virshShowVersion(ctl);
exit(EXIT_SUCCESS);

View File

@ -1329,7 +1329,7 @@ vshAdmParseArgv(vshControl *ctl, int argc, char **argv)
puts(VERSION);
exit(EXIT_SUCCESS);
}
ATTRIBUTE_FALLTHROUGH;
G_GNUC_FALLTHROUGH;
case 'V':
vshAdmShowVersion(ctl);
exit(EXIT_SUCCESS);