From 31865b25890ac23d9de9af628de6c5e9ef13c3c6 Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Mon, 20 Aug 2012 10:56:40 -0700 Subject: [PATCH] ptp4l: change interface name into static array In order to support future settings which allow for the configuration of per-port data, this patch modifies the interface name to be a static array instead of a pointer. -v2 * Minor edit for merge with previous patch Signed-off-by: Jacob Keller --- config.h | 3 ++- ptp4l.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config.h b/config.h index 8bcdbc3..306fd48 100644 --- a/config.h +++ b/config.h @@ -25,10 +25,11 @@ #include "transport.h" #define MAX_PORTS 8 +#define MAX_IFNAME_SIZE 16 /** Defines a network interface, with PTP options. */ struct interface { - char *name; + char name[MAX_IFNAME_SIZE + 1]; enum delay_mechanism dm; enum transport_type transport; }; diff --git a/ptp4l.c b/ptp4l.c index 899cc42..8c47ee1 100644 --- a/ptp4l.c +++ b/ptp4l.c @@ -152,7 +152,7 @@ int main(int argc, char *argv[]) break; case 'i': if (*nports < MAX_PORTS) { - iface[*nports].name = optarg; + strncpy(iface[*nports].name, optarg, MAX_IFNAME_SIZE); iface[*nports].dm = *dm; iface[*nports].transport = *transport; (*nports)++;