From 3b64acf7dd423bd5b3220ed9ac9e67a9c911cae9 Mon Sep 17 00:00:00 2001 From: Jeff Chen Date: Tue, 11 Dec 2018 13:26:35 +0800 Subject: [PATCH] Optimize the third parameter of write(). --- .../onlp/builds/src/module/src/platform_lib.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/platform_lib.c index a9bd01f3..1219c0cb 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/platform_lib.c @@ -272,13 +272,13 @@ int dni_i2c_lock_read_attribute(mux_info_t * mux_info, char * fullpath) int dni_i2c_lock_write_attribute(mux_info_t * mux_info, char * data,char * fullpath) { - int fd, nbytes = 10, rv = -1; + int fd, rv = -1; DNI_BUS_LOCK(); /* Create output file descriptor */ if ((fd = open(fullpath, O_WRONLY, 0644)) >= 0) { - if (write(fd, data, (ssize_t)nbytes) > 0) + if (write(fd, data, strlen(data)) > 0) { fsync(fd); rv = 0; @@ -305,7 +305,7 @@ int dni_lock_cpld_read_attribute(char *cpld_path, int addr) /* Create output file descriptor */ if ((fd = open(cpld_addr_path, O_WRONLY, 0644)) >= 0) { - if (write(fd, address, 4) > 0) + if (write(fd, address, strlen(address)) > 0) { fsync(fd); if ((fd1 = open(cpld_data_path, O_RDONLY, 0644)) >= 0) @@ -340,13 +340,13 @@ int dni_lock_cpld_write_attribute(char *cpld_path, int addr, int data) /* Create output file descriptor */ if ((fd = open(cpld_addr_path, O_WRONLY, 0644)) >= 0) { - if ((write(fd, address, 4)) > 0) + if ((write(fd, address, strlen(address))) > 0) { fsync(fd); if ((fd1 = open(cpld_data_path, O_WRONLY, 0644)) >= 0) { sprintf(datas, "0x%02x", data); - if (write(fd1, datas, 4) > 0) + if (write(fd1, datas, strlen(datas)) > 0) { fsync(fd1); rv = 0;