History

check a few times before trusting the sense

Sigrid Solveig Haflínudóttir committed 5 years ago

Commit eed67ad1 parent c5b6d2a1 file · +7 −1Browse files

Unified · Split

jacksense.c+7−1
@@ -14,7 +14,7 @@ main(int argc, char **argv) · 13 unmodified lines
14{14{
15 int hp, sp, cmd, ctl, vol, lastvol, newvol;15 int hp, sp, cmd, ctl, vol, lastvol, newvol;
16 int hpsafevol, spsafevol;16 int hpsafevol, spsafevol;
17 u32int x, y[4], has, had;17 u32int x, y[4], has, had, c;
18 Biobuf *b;18 Biobuf *b;
19 char *s, *a[16], tmp[32];19 char *s, *a[16], tmp[32];
20 20
@@ -61,10 +61,16 @@ main(int argc, char **argv) · 40 unmodified lines
61 had = -1;61 had = -1;
62 lastvol = (spsafevol < hpsafevol ? spsafevol : hpsafevol)*2/3;62 lastvol = (spsafevol < hpsafevol ? spsafevol : hpsafevol)*2/3;
63 for(;;){63 for(;;){
64 c = 0;
65again:
64 if(write(cmd, &x, 4) != 4 || read(cmd, y, sizeof(y)) < 4)66 if(write(cmd, &x, 4) != 4 || read(cmd, y, sizeof(y)) < 4)
65 sysfatal("failed");67 sysfatal("failed");
66 has = y[0] & (1<<31);68 has = y[0] & (1<<31);
67 if(has != had){69 if(has != had){
70 if(c++ < 2){
71 sleep(75);
72 goto again;
73 }
68 newvol = lastvol;74 newvol = lastvol;
69 if(pread(vol, tmp, sizeof(tmp)-1, 0) > 0 && strncmp(tmp, "master ", 7) == 0)75 if(pread(vol, tmp, sizeof(tmp)-1, 0) > 0 && strncmp(tmp, "master ", 7) == 0)
70 lastvol = atoi(tmp+7);76 lastvol = atoi(tmp+7);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t