Merge ~info-martin-konrad/epics-base:fix-compiler-warnings into ~epics-core/epics-base/+git/epics-base:3.15

Proposed by Martin Konrad
Status: Merged
Merged at revision: 2db2f1a53fb71ccb8375ea5acbe169fe007bc540
Proposed branch: ~info-martin-konrad/epics-base:fix-compiler-warnings
Merge into: ~epics-core/epics-base/+git/epics-base:3.15
Diff against target: 138 lines (+18/-14)
7 files modified
src/libCom/log/iocLogServer.c (+11/-3)
src/libCom/osi/epicsTime.cpp (+0/-3)
src/libCom/osi/epicsTime.h (+0/-1)
src/std/rec/boRecord.c (+2/-2)
src/std/rec/stateRecord.c (+1/-1)
src/std/rec/stringinRecord.c (+2/-2)
src/std/rec/stringoutRecord.c (+2/-2)
Reviewer Review Type Date Requested Status
mdavidsaver Approve
Andrew Johnson Approve
Review via email: mp+366496@code.launchpad.net

Description of the change

Fix a bunch of compiler warnings.

To post a comment you must log in.
Revision history for this message
Andrew Johnson (anj) wrote :

I don't see any obvious problems with these changes, although I haven't actually tried them. Compilers sure are getting picky nowadays...

review: Approve
Revision history for this message
mdavidsaver (mdavidsaver) wrote :

The fixes look fine to me. Though I suspect there are more potential overflows hiding in iocLogServer.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/libCom/log/iocLogServer.c b/src/libCom/log/iocLogServer.c
2index f42aa45..e707185 100644
3--- a/src/libCom/log/iocLogServer.c
4+++ b/src/libCom/log/iocLogServer.c
5@@ -37,7 +37,7 @@
6
7 static unsigned short ioc_log_port;
8 static long ioc_log_file_limit;
9-static char ioc_log_file_name[256];
10+static char ioc_log_file_name[512];
11 static char ioc_log_file_command[256];
12
13
14@@ -866,7 +866,12 @@ static int setupSIGHUP(struct ioc_log_server *pserver)
15 */
16 static void sighupHandler(int signo)
17 {
18- (void) write(sighupPipe[1], "SIGHUP\n", 7);
19+ const char msg[] = "SIGHUP\n";
20+ const ssize_t bytesWritten = write(sighupPipe[1], msg, sizeof(msg));
21+ if (bytesWritten != sizeof(msg)) {
22+ fprintf(stderr, "iocLogServer: failed to write to SIGHUP pipe because "
23+ "`%s'\n", strerror(errno));
24+ }
25 }
26
27
28@@ -884,7 +889,10 @@ static void serviceSighupRequest(void *pParam)
29 /*
30 * Read and discard message from pipe.
31 */
32- (void) read(sighupPipe[0], buff, sizeof buff);
33+ if (read(sighupPipe[0], buff, sizeof buff) <= 0) {
34+ fprintf(stderr, "iocLogServer: failed to read from SIGHUP pipe because "
35+ "`%s'\n", strerror(errno));
36+ };
37
38 /*
39 * Determine new log file name.
40diff --git a/src/libCom/osi/epicsTime.cpp b/src/libCom/osi/epicsTime.cpp
41index af4fae2..ef43e0a 100644
42--- a/src/libCom/osi/epicsTime.cpp
43+++ b/src/libCom/osi/epicsTime.cpp
44@@ -205,9 +205,6 @@ epicsTime::epicsTime (const epicsTimeStamp &ts)
45 epicsTime::epicsTime () :
46 secPastEpoch(0u), nSec(0u) {}
47
48-epicsTime::epicsTime (const epicsTime &t) :
49- secPastEpoch (t.secPastEpoch), nSec (t.nSec) {}
50-
51 epicsTime epicsTime::getCurrent ()
52 {
53 epicsTimeStamp current;
54diff --git a/src/libCom/osi/epicsTime.h b/src/libCom/osi/epicsTime.h
55index 1cb3733..d8b2663 100644
56--- a/src/libCom/osi/epicsTime.h
57+++ b/src/libCom/osi/epicsTime.h
58@@ -81,7 +81,6 @@ public:
59 class formatProblemWithStructTM {};
60
61 epicsTime ();
62- epicsTime ( const epicsTime & t );
63
64 static epicsTime getEvent ( const epicsTimeEvent & );
65 static epicsTime getCurrent ();
66diff --git a/src/std/rec/boRecord.c b/src/std/rec/boRecord.c
67index 8818455..48cc484 100644
68--- a/src/std/rec/boRecord.c
69+++ b/src/std/rec/boRecord.c
70@@ -329,9 +329,9 @@ static long get_enum_strs(DBADDR *paddr,struct dbr_enumStrs *pes)
71 /*SETTING no_str=0 breaks channel access clients*/
72 pes->no_str = 2;
73 memset(pes->strs,'\0',sizeof(pes->strs));
74- strncpy(pes->strs[0],prec->znam,sizeof(prec->znam));
75+ strncpy(pes->strs[0],prec->znam,sizeof(pes->strs[0]));
76 if(*prec->znam!=0) pes->no_str=1;
77- strncpy(pes->strs[1],prec->onam,sizeof(prec->onam));
78+ strncpy(pes->strs[1],prec->onam,sizeof(pes->strs[1]));
79 if(*prec->onam!=0) pes->no_str=2;
80 return(0);
81 }
82diff --git a/src/std/rec/stateRecord.c b/src/std/rec/stateRecord.c
83index a052b07..8170de7 100644
84--- a/src/std/rec/stateRecord.c
85+++ b/src/std/rec/stateRecord.c
86@@ -98,7 +98,7 @@ static void monitor(stateRecord *prec)
87 monitor_mask = recGblResetAlarms(prec);
88 if(strncmp(prec->oval,prec->val,sizeof(prec->val))) {
89 db_post_events(prec,&(prec->val[0]),monitor_mask|DBE_VALUE|DBE_LOG);
90- strncpy(prec->oval,prec->val,sizeof(prec->val));
91+ strncpy(prec->oval,prec->val,sizeof(prec->oval));
92 }
93 return;
94 }
95diff --git a/src/std/rec/stringinRecord.c b/src/std/rec/stringinRecord.c
96index db2f626..aac7d4e 100644
97--- a/src/std/rec/stringinRecord.c
98+++ b/src/std/rec/stringinRecord.c
99@@ -120,7 +120,7 @@ static long init_record(stringinRecord *prec, int pass)
100 if( pdset->init_record ) {
101 if((status=(*pdset->init_record)(prec))) return(status);
102 }
103- strncpy(prec->oval, prec->val, sizeof(prec->val));
104+ strncpy(prec->oval, prec->val, sizeof(prec->oval));
105 return(0);
106 }
107
108
109@@ -160,7 +160,7 @@ static void monitor(stringinRecord *prec)
110
111 if (strncmp(prec->oval, prec->val, sizeof(prec->val))) {
112 monitor_mask |= DBE_VALUE | DBE_LOG;
113- strncpy(prec->oval, prec->val, sizeof(prec->val));
114+ strncpy(prec->oval, prec->val, sizeof(prec->oval));
115 }
116
117 if (prec->mpst == stringinPOST_Always)
118diff --git a/src/std/rec/stringoutRecord.c b/src/std/rec/stringoutRecord.c
119index 2bca322..61d88f6 100644
120--- a/src/std/rec/stringoutRecord.c
121+++ b/src/std/rec/stringoutRecord.c
122@@ -122,7 +122,7 @@ static long init_record(stringoutRecord *prec, int pass)
123 if( pdset->init_record ) {
124 if((status=(*pdset->init_record)(prec))) return(status);
125 }
126- strncpy(prec->oval, prec->val, sizeof(prec->val));
127+ strncpy(prec->oval, prec->val, sizeof(prec->oval));
128 return(0);
129 }
130
131
132@@ -188,7 +188,7 @@ static void monitor(stringoutRecord *prec)
133
134 if (strncmp(prec->oval, prec->val, sizeof(prec->val))) {
135 monitor_mask |= DBE_VALUE | DBE_LOG;
136- strncpy(prec->oval, prec->val, sizeof(prec->val));
137+ strncpy(prec->oval, prec->val, sizeof(prec->oval));
138 }
139
140 if (prec->mpst == stringoutPOST_Always)

Subscribers

People subscribed via source and target branches