Files
s390-tools/zdev/include/nic.h
Jan Höppner d14051e309 zdev: Copy strings correctly using util_strlcpy()
Make sure strings are copied correctly by using util_strlcpy().

Also, rename the NIC_{OWNER,NAME}_LEN definitions to *_SIZE to make it
more clear that the terminating null byte ('\0') is included in this
buffer size. Using *_LEN would mean only the number of characters in the
string fit in.
Furthermore, use these definitions rather than sizeof().

This fixes the following GCC8 compile warning:

nic.c: In function ‘nic_data_get’:
nic.c:58:2: warning: ‘strncpy’ specified bound 9 equals destination size
[-Wstringop-truncation]
  strncpy(data.owner, argv[11], sizeof(data.owner));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nic.c:59:2: warning: ‘strncpy’ specified bound 9 equals destination size
[-Wstringop-truncation]
  strncpy(data.name, argv[12], sizeof(data.name));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:19:48 +01:00

43 lines
818 B
C

/*
* zdev - Modify and display the persistent configuration of devices
*
* Copyright IBM Corp. 2016, 2017
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#ifndef NIC_H
#define NIC_H
#include <stdbool.h>
enum nic_type {
nic_qdio,
nic_hipers,
nic_iedn,
nic_inmn,
};
enum nic_target {
nic_vswitch,
nic_lan,
};
#define NIC_OWNER_SIZE 9
#define NIC_NAME_SIZE 9
struct nic_data {
enum nic_type type;
enum nic_target target;
char owner[NIC_OWNER_SIZE];
char name[NIC_NAME_SIZE];
};
bool nic_data_get(const char *, struct nic_data *);
void nic_data_print(struct nic_data *, int);
bool nic_vswitch_get_layer2(const char *, int *);
bool nic_lan_get_layer2(const char *, const char *, int *);
#endif /* NIC_H */