aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2012-01-10 17:38:54 +0000
committerJonathan McCrohan <jmccrohan@gmail.com>2012-01-10 17:38:54 +0000
commit94dc9792a9f636771ea1388f395ca89a2d07c74b (patch)
treebdbb2ba55ba54f60ee6dbce5ffa2599790fc036d /src
parentfef836a534ace8c5bcf0c473d6c5435d0aaa5452 (diff)
downloadverteco-94dc9792a9f636771ea1388f395ca89a2d07c74b.tar.gz
Handle 32bit signed overflow.
Diffstat (limited to 'src')
-rw-r--r--src/modbuslog.c7
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);