Fossil SCM

Fix several harmless compiler warnings.

drh 2011-08-23 15:45 trunk
Commit 553159aa0d9a8206be973cd2081c720a71b0c2d4
3 files changed +1 -1 +11 -5 +6 -2
+1 -1
--- src/blob.c
+++ src/blob.c
@@ -120,11 +120,11 @@
120120
** This routine is called if a blob operation fails because we
121121
** have run out of memory.
122122
*/
123123
static void blob_panic(void){
124124
static const char zErrMsg[] = "out of memory\n";
125
- write(2, zErrMsg, sizeof(zErrMsg)-1);
125
+ fputs(zErrMsg, stderr);
126126
fossil_exit(1);
127127
}
128128
129129
/*
130130
** A reallocation function that assumes that aData came from malloc().
131131
--- src/blob.c
+++ src/blob.c
@@ -120,11 +120,11 @@
120 ** This routine is called if a blob operation fails because we
121 ** have run out of memory.
122 */
123 static void blob_panic(void){
124 static const char zErrMsg[] = "out of memory\n";
125 write(2, zErrMsg, sizeof(zErrMsg)-1);
126 fossil_exit(1);
127 }
128
129 /*
130 ** A reallocation function that assumes that aData came from malloc().
131
--- src/blob.c
+++ src/blob.c
@@ -120,11 +120,11 @@
120 ** This routine is called if a blob operation fails because we
121 ** have run out of memory.
122 */
123 static void blob_panic(void){
124 static const char zErrMsg[] = "out of memory\n";
125 fputs(zErrMsg, stderr);
126 fossil_exit(1);
127 }
128
129 /*
130 ** A reallocation function that assumes that aData came from malloc().
131
+11 -5
--- src/cgi.c
+++ src/cgi.c
@@ -1153,11 +1153,13 @@
11531153
fossil_print("Listening for HTTP requests on TCP port %d\n", iPort);
11541154
fflush(stdout);
11551155
}
11561156
if( zBrowser ){
11571157
zBrowser = mprintf(zBrowser, iPort);
1158
- system(zBrowser);
1158
+ if( system(zBrowser)<0 ){
1159
+ fossil_warning("cannot start browser: %s\n", zBrowser);
1160
+ }
11591161
}
11601162
while( 1 ){
11611163
if( nchildren>MAX_PARALLEL ){
11621164
/* Slow down if connections are arriving too fast */
11631165
sleep( nchildren-MAX_PARALLEL );
@@ -1174,20 +1176,24 @@
11741176
child = fork();
11751177
if( child!=0 ){
11761178
if( child>0 ) nchildren++;
11771179
close(connection);
11781180
}else{
1181
+ int nErr = 0, fd;
11791182
close(0);
1180
- dup(connection);
1183
+ fd = dup(connection);
1184
+ if( fd!=0 ) nErr++;
11811185
close(1);
1182
- dup(connection);
1186
+ fd = dup(connection);
1187
+ if( fd!=1 ) nErr++;
11831188
if( !g.fHttpTrace && !g.fSqlTrace ){
11841189
close(2);
1185
- dup(connection);
1190
+ fd = dup(connection);
1191
+ if( fd!=2 ) nErr++;
11861192
}
11871193
close(connection);
1188
- return 0;
1194
+ return nErr;
11891195
}
11901196
}
11911197
}
11921198
/* Bury dead children */
11931199
while( waitpid(0, 0, WNOHANG)>0 ){
11941200
--- src/cgi.c
+++ src/cgi.c
@@ -1153,11 +1153,13 @@
1153 fossil_print("Listening for HTTP requests on TCP port %d\n", iPort);
1154 fflush(stdout);
1155 }
1156 if( zBrowser ){
1157 zBrowser = mprintf(zBrowser, iPort);
1158 system(zBrowser);
 
 
1159 }
1160 while( 1 ){
1161 if( nchildren>MAX_PARALLEL ){
1162 /* Slow down if connections are arriving too fast */
1163 sleep( nchildren-MAX_PARALLEL );
@@ -1174,20 +1176,24 @@
1174 child = fork();
1175 if( child!=0 ){
1176 if( child>0 ) nchildren++;
1177 close(connection);
1178 }else{
 
1179 close(0);
1180 dup(connection);
 
1181 close(1);
1182 dup(connection);
 
1183 if( !g.fHttpTrace && !g.fSqlTrace ){
1184 close(2);
1185 dup(connection);
 
1186 }
1187 close(connection);
1188 return 0;
1189 }
1190 }
1191 }
1192 /* Bury dead children */
1193 while( waitpid(0, 0, WNOHANG)>0 ){
1194
--- src/cgi.c
+++ src/cgi.c
@@ -1153,11 +1153,13 @@
1153 fossil_print("Listening for HTTP requests on TCP port %d\n", iPort);
1154 fflush(stdout);
1155 }
1156 if( zBrowser ){
1157 zBrowser = mprintf(zBrowser, iPort);
1158 if( system(zBrowser)<0 ){
1159 fossil_warning("cannot start browser: %s\n", zBrowser);
1160 }
1161 }
1162 while( 1 ){
1163 if( nchildren>MAX_PARALLEL ){
1164 /* Slow down if connections are arriving too fast */
1165 sleep( nchildren-MAX_PARALLEL );
@@ -1174,20 +1176,24 @@
1176 child = fork();
1177 if( child!=0 ){
1178 if( child>0 ) nchildren++;
1179 close(connection);
1180 }else{
1181 int nErr = 0, fd;
1182 close(0);
1183 fd = dup(connection);
1184 if( fd!=0 ) nErr++;
1185 close(1);
1186 fd = dup(connection);
1187 if( fd!=1 ) nErr++;
1188 if( !g.fHttpTrace && !g.fSqlTrace ){
1189 close(2);
1190 fd = dup(connection);
1191 if( fd!=2 ) nErr++;
1192 }
1193 close(connection);
1194 return nErr;
1195 }
1196 }
1197 }
1198 /* Bury dead children */
1199 while( waitpid(0, 0, WNOHANG)>0 ){
1200
+6 -2
--- src/popen.c
+++ src/popen.c
@@ -172,17 +172,21 @@
172172
close(pout[1]);
173173
*pChildPid = 0;
174174
return 1;
175175
}
176176
if( *pChildPid==0 ){
177
+ int fd;
178
+ int nErr = 0;
177179
/* This is the child process */
178180
close(0);
179
- dup(pout[0]);
181
+ fd = dup(pout[0]);
182
+ if( fd!=0 ) nErr++;
180183
close(pout[0]);
181184
close(pout[1]);
182185
close(1);
183
- dup(pin[1]);
186
+ fd = dup(pin[1]);
187
+ if( fd!=1 ) nErr++;
184188
close(pin[0]);
185189
close(pin[1]);
186190
execl("/bin/sh", "/bin/sh", "-c", zCmd, (char*)0);
187191
return 1;
188192
}else{
189193
--- src/popen.c
+++ src/popen.c
@@ -172,17 +172,21 @@
172 close(pout[1]);
173 *pChildPid = 0;
174 return 1;
175 }
176 if( *pChildPid==0 ){
 
 
177 /* This is the child process */
178 close(0);
179 dup(pout[0]);
 
180 close(pout[0]);
181 close(pout[1]);
182 close(1);
183 dup(pin[1]);
 
184 close(pin[0]);
185 close(pin[1]);
186 execl("/bin/sh", "/bin/sh", "-c", zCmd, (char*)0);
187 return 1;
188 }else{
189
--- src/popen.c
+++ src/popen.c
@@ -172,17 +172,21 @@
172 close(pout[1]);
173 *pChildPid = 0;
174 return 1;
175 }
176 if( *pChildPid==0 ){
177 int fd;
178 int nErr = 0;
179 /* This is the child process */
180 close(0);
181 fd = dup(pout[0]);
182 if( fd!=0 ) nErr++;
183 close(pout[0]);
184 close(pout[1]);
185 close(1);
186 fd = dup(pin[1]);
187 if( fd!=1 ) nErr++;
188 close(pin[0]);
189 close(pin[1]);
190 execl("/bin/sh", "/bin/sh", "-c", zCmd, (char*)0);
191 return 1;
192 }else{
193

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button