static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,

                          const char *name, Error **errp)

{

    DeviceState *dev = DEVICE(obj);

    Property *prop = opaque;

    uint32_t *ptr = qdev_get_prop_ptr(dev, prop);

    unsigned int slot, fn, n;

    Error *local_err = NULL;

    char *str = (char *)"";



    if (dev->state != DEV_STATE_CREATED) {

        error_set(errp, QERR_PERMISSION_DENIED);

        return;

    }



    visit_type_str(v, &str, name, &local_err);

    if (local_err) {

        error_free(local_err);

        return set_int32(obj, v, opaque, name, errp);

    }



    if (sscanf(str, "%x.%x%n", &slot, &fn, &n) != 2) {

        fn = 0;

        if (sscanf(str, "%x%n", &slot, &n) != 1) {

            goto invalid;

        }

    }

    if (str[n] != '\0' || fn > 7 || slot > 31) {

        goto invalid;

    }

    *ptr = slot << 3 | fn;

    return;



invalid:

    error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);

}

static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,

                          const char *name, Error **errp)

{

    DeviceState *dev = DEVICE(obj);

    Property *prop = opaque;

    uint32_t *ptr = qdev_get_prop_ptr(dev, prop);

    unsigned int slot, fn, n;

    Error *local_err = NULL;

    char *str = (char *)"";



    if (dev->state != DEV_STATE_CREATED) {

        error_set(errp, QERR_PERMISSION_DENIED);

        return;

    }



    visit_type_str(v, &str, name, &local_err);

    if (local_err) {

        error_free(local_err);

        return set_int32(obj, v, opaque, name, errp);

    }



    if (sscanf(str, "%x.%x%n", &slot, &fn, &n) != 2) {

        fn = 0;

        if (sscanf(str, "%x%n", &slot, &n) != 1) {

            goto invalid;

        }

    }

    if (str[n] != '\0' || fn > 7 || slot > 31) {

        goto invalid;

    }

    *ptr = slot << 3 | fn;

    return;



invalid:

    error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);

}

    char *str = (char *)"";
static void FUNC_0(Object *VAR_0, Visitor *VAR_1, void *VAR_2,

                          const char *VAR_3, Error **VAR_4)

{

    DeviceState *dev = DEVICE(VAR_0);

    Property *prop = VAR_2;

    uint32_t *ptr = qdev_get_prop_ptr(dev, prop);

    unsigned int VAR_5, VAR_6, VAR_7;

    Error *local_err = NULL;

    char *VAR_8 = (char *)"";



    if (dev->state != DEV_STATE_CREATED) {

        error_set(VAR_4, QERR_PERMISSION_DENIED);

        return;

    }



    visit_type_str(VAR_1, &VAR_8, VAR_3, &local_err);

    if (local_err) {

        error_free(local_err);

        return set_int32(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);

    }



    if (sscanf(VAR_8, "%x.%x%VAR_7", &VAR_5, &VAR_6, &VAR_7) != 2) {

        VAR_6 = 0;

        if (sscanf(VAR_8, "%x%VAR_7", &VAR_5, &VAR_7) != 1) {

            goto invalid;

        }

    }

    if (VAR_8[VAR_7] != '\0' || VAR_6 > 7 || VAR_5 > 31) {

        goto invalid;

    }

    *ptr = VAR_5 << 3 | VAR_6;

    return;



invalid:

    error_set_from_qdev_prop_error(VAR_4, EINVAL, dev, prop, VAR_8);

}

static void FUNC_0(Object *VAR_0, Visitor *VAR_1, void *VAR_2,
const char *VAR_3, Error **VAR_4)
{ DeviceState *dev = DEVICE(VAR_0); Property *prop = VAR_2; uint32_t *ptr = qdev_get_prop_ptr(dev, prop); unsigned int VAR_5, VAR_6, VAR_7; Error *local_err = NULL; char *VAR_8 = (char *)""; if (dev->state != DEV_STATE_CREATED) { error_set(VAR_4, QERR_PERMISSION_DENIED); return; } visit_type_str(VAR_1, &VAR_8, VAR_3, &local_err); if (local_err) { error_free(local_err); return set_int32(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4); } if (sscanf(VAR_8, "%x.%x%VAR_7", &VAR_5, &VAR_6, &VAR_7) != 2) { VAR_6 = 0; if (sscanf(VAR_8, "%x%VAR_7", &VAR_5, &VAR_7) != 1) { goto invalid; } } if (VAR_8[VAR_7] != '\0' || VAR_6 > 7 || VAR_5 > 31) { goto invalid; } *ptr = VAR_5 << 3 | VAR_6; return; invalid:
error_set_from_qdev_prop_error(VAR_4, EINVAL, dev, prop, VAR_8); }