static int kvmppc_read_host_property(const char *node_path, const char *prop,

                                     void *val, size_t len)

{

    char *path;

    FILE *f;

    int ret;

    int pathlen;



    pathlen = snprintf(NULL, 0, "%s/%s/%s", PROC_DEVTREE_PATH, node_path, prop)

              + 1;

    path = qemu_malloc(pathlen);

    if (path == NULL) {

        ret = -ENOMEM;

        goto out;

    }



    snprintf(path, pathlen, "%s/%s/%s", PROC_DEVTREE_PATH, node_path, prop);



    f = fopen(path, "rb");

    if (f == NULL) {

        ret = errno;

        goto free;

    }



    len = fread(val, len, 1, f);

    if (len != 1) {

        ret = ferror(f);

        goto close;

    }



close:

    fclose(f);

free:

    free(path);

out:

    return ret;

}

static int kvmppc_read_host_property(const char *node_path, const char *prop,

                                     void *val, size_t len)

{

    char *path;

    FILE *f;

    int ret;

    int pathlen;



    pathlen = snprintf(NULL, 0, "%s/%s/%s", PROC_DEVTREE_PATH, node_path, prop)

              + 1;

    path = qemu_malloc(pathlen);

    if (path == NULL) {

        ret = -ENOMEM;

        goto out;

    }



    snprintf(path, pathlen, "%s/%s/%s", PROC_DEVTREE_PATH, node_path, prop);



    f = fopen(path, "rb");

    if (f == NULL) {

        ret = errno;

        goto free;

    }



    len = fread(val, len, 1, f);

    if (len != 1) {

        ret = ferror(f);

        goto close;

    }



close:

    fclose(f);

free:

    free(path);

out:

    return ret;

}

    int ret;
static int FUNC_0(const char *VAR_0, const char *VAR_1,

                                     void *VAR_2, size_t VAR_3)

{

    char *VAR_4;

    FILE *f;

    int VAR_5;

    int VAR_6;



    VAR_6 = snprintf(NULL, 0, "%s/%s/%s", PROC_DEVTREE_PATH, VAR_0, VAR_1)

              + 1;

    VAR_4 = qemu_malloc(VAR_6);

    if (VAR_4 == NULL) {

        VAR_5 = -ENOMEM;

        goto out;

    }



    snprintf(VAR_4, VAR_6, "%s/%s/%s", PROC_DEVTREE_PATH, VAR_0, VAR_1);



    f = fopen(VAR_4, "rb");

    if (f == NULL) {

        VAR_5 = errno;

        goto free;

    }



    VAR_3 = fread(VAR_2, VAR_3, 1, f);

    if (VAR_3 != 1) {

        VAR_5 = ferror(f);

        goto close;

    }



close:

    fclose(f);

free:

    free(VAR_4);

out:

    return VAR_5;

}

static int FUNC_0(const char *VAR_0, const char *VAR_1,
void *VAR_2, size_t VAR_3)
{ char *VAR_4; FILE *f; int VAR_5; int VAR_6; VAR_6 = snprintf(NULL, 0, "%s/%s/%s", PROC_DEVTREE_PATH, VAR_0, VAR_1)
+ 1; VAR_4 = qemu_malloc(VAR_6); if (VAR_4 == NULL) { VAR_5 = -ENOMEM; goto out; } snprintf(VAR_4, VAR_6, "%s/%s/%s", PROC_DEVTREE_PATH, VAR_0, VAR_1); f = fopen(VAR_4, "rb"); if (f == NULL) { VAR_5 = errno; goto free; } VAR_3 = fread(VAR_2, VAR_3, 1, f); if (VAR_3 != 1) { VAR_5 = ferror(f); goto close; } close:
fclose(f); free:
free(VAR_4); out:
return VAR_5; }