diff options
Diffstat (limited to 'src/modbuslog.c')
-rw-r--r-- | src/modbuslog.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/modbuslog.c b/src/modbuslog.c index e7ccb05..1e849bb 100644 --- a/src/modbuslog.c +++ b/src/modbuslog.c @@ -309,7 +309,12 @@ int main(int argc, char *argv[]) { int intervalid; FILE *intervalfile = fopen("/var/modbuslog/interval/interval.txt", "r+"); fscanf(intervalfile, "%d", &intervalid); - intervalid++; + //handle 32bit signed overflow + if(intervalid==2147483647){ + intervalid=0; + }else{ + intervalid++; + } rewind(intervalfile); fprintf(intervalfile, "%d", intervalid); fclose(intervalfile); |