mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-30 17:18:21 +03:00
use memcpy for constant ondisk strings
Use memcpy/memcmp for on disk strings which are not null terminated: FMTT_MAGIC, LVM2_LABEL and LABEL_ID. Quiets compile warnings.
This commit is contained in:
parent
adfb9bf20c
commit
0046c4e7a7
lib
@ -333,7 +333,7 @@ static int _raw_read_mda_header(struct mda_header *mdah, struct device_area *dev
|
||||
|
||||
_xlate_mdah(mdah);
|
||||
|
||||
if (strncmp((char *)mdah->magic, FMTT_MAGIC, sizeof(mdah->magic))) {
|
||||
if (memcmp(mdah->magic, FMTT_MAGIC, sizeof(mdah->magic))) {
|
||||
log_error("Wrong magic number in metadata area header on %s at %llu",
|
||||
dev_name(dev_area->dev), (unsigned long long)dev_area->start);
|
||||
return 0;
|
||||
@ -378,7 +378,7 @@ static int _raw_write_mda_header(const struct format_type *fmt,
|
||||
struct device *dev, int primary_mda,
|
||||
uint64_t start_byte, struct mda_header *mdah)
|
||||
{
|
||||
strncpy((char *)mdah->magic, FMTT_MAGIC, sizeof(mdah->magic));
|
||||
memcpy(mdah->magic, FMTT_MAGIC, sizeof(mdah->magic));
|
||||
mdah->version = FMTT_VERSION;
|
||||
mdah->start = start_byte;
|
||||
|
||||
|
@ -30,7 +30,7 @@ static int _text_can_handle(struct labeller *l __attribute__((unused)),
|
||||
{
|
||||
struct label_header *lh = (struct label_header *) buf;
|
||||
|
||||
if (!strncmp((char *)lh->type, LVM2_LABEL, sizeof(lh->type)))
|
||||
if (!memcmp(lh->type, LVM2_LABEL, sizeof(lh->type)))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
@ -95,9 +95,9 @@ static int _text_write(struct label *label, void *buf)
|
||||
* PV header base
|
||||
*/
|
||||
/* FIXME Move to where label is created */
|
||||
strncpy(label->type, LVM2_LABEL, sizeof(label->type));
|
||||
memcpy(label->type, LVM2_LABEL, sizeof(label->type));
|
||||
|
||||
strncpy((char *)lh->type, label->type, sizeof(label->type));
|
||||
memcpy(lh->type, LVM2_LABEL, sizeof(lh->type));
|
||||
|
||||
pvhdr = (struct pv_header *) ((char *) buf + xlate32(lh->offset_xl));
|
||||
info = (struct lvmcache_info *) label->info;
|
||||
@ -314,7 +314,7 @@ void del_mdas(struct dm_list *mdas)
|
||||
static int _text_initialise_label(struct labeller *l __attribute__((unused)),
|
||||
struct label *label)
|
||||
{
|
||||
strncpy(label->type, LVM2_LABEL, sizeof(label->type));
|
||||
memcpy(label->type, LVM2_LABEL, sizeof(label->type));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ int label_remove(struct device *dev)
|
||||
|
||||
wipe = 0;
|
||||
|
||||
if (!strncmp((char *)lh->id, LABEL_ID, sizeof(lh->id))) {
|
||||
if (!memcmp(lh->id, LABEL_ID, sizeof(lh->id))) {
|
||||
if (xlate64(lh->sector_xl) == sector)
|
||||
wipe = 1;
|
||||
} else {
|
||||
@ -192,7 +192,7 @@ int label_write(struct device *dev, struct label *label)
|
||||
|
||||
memset(buf, 0, LABEL_SIZE);
|
||||
|
||||
strncpy((char *)lh->id, LABEL_ID, sizeof(lh->id));
|
||||
memcpy(lh->id, LABEL_ID, sizeof(lh->id));
|
||||
lh->sector_xl = xlate64(label->sector);
|
||||
lh->offset_xl = xlate32(sizeof(*lh));
|
||||
|
||||
@ -293,7 +293,7 @@ static struct labeller *_find_lvm_header(struct device *dev,
|
||||
|
||||
lh = (struct label_header *) (scan_buf + (sector << SECTOR_SHIFT));
|
||||
|
||||
if (!strncmp((char *)lh->id, LABEL_ID, sizeof(lh->id))) {
|
||||
if (!memcmp(lh->id, LABEL_ID, sizeof(lh->id))) {
|
||||
if (found) {
|
||||
log_error("Ignoring additional label on %s at sector %llu",
|
||||
dev_name(dev), (unsigned long long)(block_sector + sector));
|
||||
|
Loading…
Reference in New Issue
Block a user