The builtin struct fdisk_parttypes are not supposed to be modified.
This is enforced in the mutation functions.
While the API could be cleaned up to distinguish between const and
non-const versions of fdisk_parttype this could break user code.
Instead preserve the API and add some internal casts.
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
};
#define BSD_DKMAXTYPES (ARRAY_SIZE(bsd_dktypenames) - 1)
-static struct fdisk_parttype bsd_fstypes[] = {
+static const struct fdisk_parttype bsd_fstypes[] = {
{BSD_FS_UNUSED, "unused"},
{BSD_FS_SWAP, "swap"},
{BSD_FS_V6, "Version 6"},
/*
* Partition types
*/
-static struct fdisk_parttype dos_parttypes[] = {
+static const struct fdisk_parttype dos_parttypes[] = {
#include "pt-mbr-partnames.h"
};
struct fdisk_label {
const char *name; /* label name */
enum fdisk_labeltype id; /* FDISK_DISKLABEL_* */
- struct fdisk_parttype *parttypes; /* supported partitions types */
+ const struct fdisk_parttype *parttypes; /* supported partitions types */
size_t nparttypes; /* number of items in parttypes[] */
const struct fdisk_shortcut *parttype_cuts; /* partition type shortcuts */
.name = (_n), \
}
-static struct fdisk_parttype gpt_parttypes[] =
+static const struct fdisk_parttype gpt_parttypes[] =
{
#include "pt-gpt-partnames.h"
};
{
if (!lb || n >= lb->nparttypes)
return NULL;
- return &lb->parttypes[n];
+ return (struct fdisk_parttype *)&lb->parttypes[n];
}
/**
for (i = 0; i < lb->nparttypes; i++)
if (lb->parttypes[i].code == code)
- return &lb->parttypes[i];
+ return (struct fdisk_parttype *)&lb->parttypes[i];
return NULL;
}
for (i = 0; i < lb->nparttypes; i++)
if (lb->parttypes[i].typestr
&& strcasecmp(lb->parttypes[i].typestr, str) == 0)
- return &lb->parttypes[i];
+ return (struct fdisk_parttype *)&lb->parttypes[i];
return NULL;
}
unsigned int *xcode,
int use_seqnum)
{
- struct fdisk_parttype *types, *ret = NULL;
+ const struct fdisk_parttype *types;
+ struct fdisk_parttype *ret = NULL;
char *end = NULL;
assert(lb);
if (use_seqnum && errno == 0
&& *end == '\0' && i > 0
&& i - 1 < (int) lb->nparttypes)
- ret = &types[i - 1];
+ ret = (struct fdisk_parttype *)&types[i - 1];
}
}
const char *name = lb->parttypes[i].name;
if (name && *name && ul_stralnumcmp(name, str) == 0)
- return &lb->parttypes[i];
+ return (struct fdisk_parttype *)&lb->parttypes[i];
}
return NULL;
} freelist[SGI_MAXPARTITIONS + 1];
};
-static struct fdisk_parttype sgi_parttypes[] =
+static const struct fdisk_parttype sgi_parttypes[] =
{
{SGI_TYPE_VOLHDR, N_("SGI volhdr")},
{SGI_TYPE_TRKREPL, N_("SGI trkrepl")},
struct sun_disklabel *header; /* on-disk data (pointer to cxt->firstsector) */
};
-static struct fdisk_parttype sun_parttypes[] = {
+static const struct fdisk_parttype sun_parttypes[] = {
{SUN_TAG_UNASSIGNED, N_("Unassigned")},
{SUN_TAG_BOOT, N_("Boot")},
{SUN_TAG_ROOT, N_("SunOS root")},