From 1837ee17e201c66ed13ae1665a08a92fc42cb347 Mon Sep 17 00:00:00 2001 From: Ankit Kumar Date: Tue, 5 Dec 2017 14:56:12 +0530 Subject: [PATCH 2/6] diags: Increase buffer length size to read complete system vpd information System vpd information(system id, model) can have prefix substring as IBM and hence our buffer must handle those extra string to get correct serial number and model information. This patch increased buffer length to 16 bytes(8-serial/model number + 8 - to capture other substring). Signed-off-by: Ankit Kumar Signed-off-by: Vasant Hegde --- diags/diag_disk.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/diags/diag_disk.c b/diags/diag_disk.c index 5a6c84b..fb24a72 100644 --- a/diags/diag_disk.c +++ b/diags/diag_disk.c @@ -44,6 +44,7 @@ #define DEVICE_TREE_SYSTEM_ID DEVICE_TREE"system-id" #define DEVICE_TREE_MODEL DEVICE_TREE"model" +#define BUFFER_LENGTH 16 #define SERIAL_NUM_LEN 8 #define MACHINE_MODEL_LEN 8 @@ -196,15 +197,15 @@ static int get_system_vpd(char *machine_serial, int device_fd; int rc; int start_index = 0; - char serial[SERIAL_NUM_LEN + 1] = {0}; - char model[MACHINE_MODEL_LEN + 1] = {0}; + char serial[BUFFER_LENGTH] = {0}; + char model[BUFFER_LENGTH] = {0}; char *temp; device_fd = open(DEVICE_TREE_SYSTEM_ID, O_RDONLY); if (device_fd < 0) return -1; - rc = read(device_fd, serial, SERIAL_NUM_LEN); + rc = read(device_fd, serial, BUFFER_LENGTH); close(device_fd); if (rc <= 0) return -1; @@ -218,7 +219,7 @@ static int get_system_vpd(char *machine_serial, if (device_fd < 0) return -1; - rc = read(device_fd, model, MACHINE_MODEL_LEN); + rc = read(device_fd, model, BUFFER_LENGTH); close(device_fd); if (rc <= 0) return -1; -- 2.14.3