Fossil SCM

Additional compiler warning fixes.

drh 2010-10-14 19:23 trunk
Commit c345445cad799c89c90a69556717a794e771be94
+4 -5
--- src/cgi.c
+++ src/cgi.c
@@ -941,11 +941,11 @@
941941
*/
942942
void cgi_handle_http_request(const char *zIpAddr){
943943
char *z, *zToken;
944944
int i;
945945
struct sockaddr_in remoteName;
946
- size_t size = sizeof(struct sockaddr_in);
946
+ socklen_t size = sizeof(struct sockaddr_in);
947947
char zLine[2000]; /* A single line of input. */
948948
949949
g.fullHttpReply = 1;
950950
if( fgets(zLine, sizeof(zLine),g.httpIn)==0 ){
951951
malformed_request();
@@ -969,11 +969,11 @@
969969
if( zToken[i] ) zToken[i++] = 0;
970970
cgi_setenv("PATH_INFO", zToken);
971971
cgi_setenv("QUERY_STRING", &zToken[i]);
972972
if( zIpAddr==0 &&
973973
getpeername(fileno(g.httpIn), (struct sockaddr*)&remoteName,
974
- (socklen_t*)&size)>=0
974
+ &size)>=0
975975
){
976976
zIpAddr = inet_ntoa(remoteName.sin_addr);
977977
}
978978
if( zIpAddr ){
979979
cgi_setenv("REMOTE_ADDR", zIpAddr);
@@ -1052,11 +1052,11 @@
10521052
fossil_exit(1);
10531053
#else
10541054
int listener = -1; /* The server socket */
10551055
int connection; /* A socket for each individual connection */
10561056
fd_set readfds; /* Set of file descriptors for select() */
1057
- size_t lenaddr; /* Length of the inaddr structure */
1057
+ socklen_t lenaddr; /* Length of the inaddr structure */
10581058
int child; /* PID of the child process */
10591059
int nchildren = 0; /* Number of child processes */
10601060
struct timeval delay; /* How long to wait inside select() */
10611061
struct sockaddr_in inaddr; /* The socket address */
10621062
int opt = 1; /* setsockopt flag */
@@ -1115,12 +1115,11 @@
11151115
FD_ZERO(&readfds);
11161116
FD_SET( listener, &readfds);
11171117
select( listener+1, &readfds, 0, 0, &delay);
11181118
if( FD_ISSET(listener, &readfds) ){
11191119
lenaddr = sizeof(inaddr);
1120
- connection = accept(listener, (struct sockaddr*)&inaddr,
1121
- (socklen_t*) &lenaddr);
1120
+ connection = accept(listener, (struct sockaddr*)&inaddr, &lenaddr);
11221121
if( connection>=0 ){
11231122
child = fork();
11241123
if( child!=0 ){
11251124
if( child>0 ) nchildren++;
11261125
close(connection);
11271126
--- src/cgi.c
+++ src/cgi.c
@@ -941,11 +941,11 @@
941 */
942 void cgi_handle_http_request(const char *zIpAddr){
943 char *z, *zToken;
944 int i;
945 struct sockaddr_in remoteName;
946 size_t size = sizeof(struct sockaddr_in);
947 char zLine[2000]; /* A single line of input. */
948
949 g.fullHttpReply = 1;
950 if( fgets(zLine, sizeof(zLine),g.httpIn)==0 ){
951 malformed_request();
@@ -969,11 +969,11 @@
969 if( zToken[i] ) zToken[i++] = 0;
970 cgi_setenv("PATH_INFO", zToken);
971 cgi_setenv("QUERY_STRING", &zToken[i]);
972 if( zIpAddr==0 &&
973 getpeername(fileno(g.httpIn), (struct sockaddr*)&remoteName,
974 (socklen_t*)&size)>=0
975 ){
976 zIpAddr = inet_ntoa(remoteName.sin_addr);
977 }
978 if( zIpAddr ){
979 cgi_setenv("REMOTE_ADDR", zIpAddr);
@@ -1052,11 +1052,11 @@
1052 fossil_exit(1);
1053 #else
1054 int listener = -1; /* The server socket */
1055 int connection; /* A socket for each individual connection */
1056 fd_set readfds; /* Set of file descriptors for select() */
1057 size_t lenaddr; /* Length of the inaddr structure */
1058 int child; /* PID of the child process */
1059 int nchildren = 0; /* Number of child processes */
1060 struct timeval delay; /* How long to wait inside select() */
1061 struct sockaddr_in inaddr; /* The socket address */
1062 int opt = 1; /* setsockopt flag */
@@ -1115,12 +1115,11 @@
1115 FD_ZERO(&readfds);
1116 FD_SET( listener, &readfds);
1117 select( listener+1, &readfds, 0, 0, &delay);
1118 if( FD_ISSET(listener, &readfds) ){
1119 lenaddr = sizeof(inaddr);
1120 connection = accept(listener, (struct sockaddr*)&inaddr,
1121 (socklen_t*) &lenaddr);
1122 if( connection>=0 ){
1123 child = fork();
1124 if( child!=0 ){
1125 if( child>0 ) nchildren++;
1126 close(connection);
1127
--- src/cgi.c
+++ src/cgi.c
@@ -941,11 +941,11 @@
941 */
942 void cgi_handle_http_request(const char *zIpAddr){
943 char *z, *zToken;
944 int i;
945 struct sockaddr_in remoteName;
946 socklen_t size = sizeof(struct sockaddr_in);
947 char zLine[2000]; /* A single line of input. */
948
949 g.fullHttpReply = 1;
950 if( fgets(zLine, sizeof(zLine),g.httpIn)==0 ){
951 malformed_request();
@@ -969,11 +969,11 @@
969 if( zToken[i] ) zToken[i++] = 0;
970 cgi_setenv("PATH_INFO", zToken);
971 cgi_setenv("QUERY_STRING", &zToken[i]);
972 if( zIpAddr==0 &&
973 getpeername(fileno(g.httpIn), (struct sockaddr*)&remoteName,
974 &size)>=0
975 ){
976 zIpAddr = inet_ntoa(remoteName.sin_addr);
977 }
978 if( zIpAddr ){
979 cgi_setenv("REMOTE_ADDR", zIpAddr);
@@ -1052,11 +1052,11 @@
1052 fossil_exit(1);
1053 #else
1054 int listener = -1; /* The server socket */
1055 int connection; /* A socket for each individual connection */
1056 fd_set readfds; /* Set of file descriptors for select() */
1057 socklen_t lenaddr; /* Length of the inaddr structure */
1058 int child; /* PID of the child process */
1059 int nchildren = 0; /* Number of child processes */
1060 struct timeval delay; /* How long to wait inside select() */
1061 struct sockaddr_in inaddr; /* The socket address */
1062 int opt = 1; /* setsockopt flag */
@@ -1115,12 +1115,11 @@
1115 FD_ZERO(&readfds);
1116 FD_SET( listener, &readfds);
1117 select( listener+1, &readfds, 0, 0, &delay);
1118 if( FD_ISSET(listener, &readfds) ){
1119 lenaddr = sizeof(inaddr);
1120 connection = accept(listener, (struct sockaddr*)&inaddr, &lenaddr);
 
1121 if( connection>=0 ){
1122 child = fork();
1123 if( child!=0 ){
1124 if( child>0 ) nchildren++;
1125 close(connection);
1126
+23
--- src/config.h
+++ src/config.h
@@ -99,10 +99,33 @@
9999
** that is more than MX_CKIN_MSG from the beginning, or at the first
100100
** paragraph break that is more than MN_CKIN_MSG from the beginning.
101101
*/
102102
#define MN_CKIN_MSG 100
103103
#define MX_CKIN_MSG 300
104
+
105
+/*
106
+** The following macros are used to cast pointers to integers and
107
+** integers to pointers. The way you do this varies from one compiler
108
+** to the next, so we have developed the following set of #if statements
109
+** to generate appropriate macros for a wide range of compilers.
110
+**
111
+** The correct "ANSI" way to do this is to use the intptr_t type.
112
+** Unfortunately, that typedef is not available on all compilers, or
113
+** if it is available, it requires an #include of specific headers
114
+** that vary from one machine to the next.
115
+*/
116
+#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
117
+# define FOSSIL_INT_TO_PTR(X) ((void*)(__PTRDIFF_TYPE__)(X))
118
+# define FOSSIL_PTR_TO_INT(X) ((int)(__PTRDIFF_TYPE__)(X))
119
+#elif !defined(__GNUC__) /* Works for compilers other than LLVM */
120
+# define FOSSIL_INT_TO_PTR(X) ((void*)&((char*)0)[X])
121
+# define FOSSIL_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0))
122
+#else /* Generates a warning - but it always works */
123
+# define FOSSIL_INT_TO_PTR(X) ((void*)(X))
124
+# define FOSSIL_PTR_TO_INT(X) ((int)(X))
125
+#endif
126
+
104127
105128
/* Unset the following to disable internationalization code. */
106129
#ifndef FOSSIL_I18N
107130
# define FOSSIL_I18N 1
108131
#endif
109132
--- src/config.h
+++ src/config.h
@@ -99,10 +99,33 @@
99 ** that is more than MX_CKIN_MSG from the beginning, or at the first
100 ** paragraph break that is more than MN_CKIN_MSG from the beginning.
101 */
102 #define MN_CKIN_MSG 100
103 #define MX_CKIN_MSG 300
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
105 /* Unset the following to disable internationalization code. */
106 #ifndef FOSSIL_I18N
107 # define FOSSIL_I18N 1
108 #endif
109
--- src/config.h
+++ src/config.h
@@ -99,10 +99,33 @@
99 ** that is more than MX_CKIN_MSG from the beginning, or at the first
100 ** paragraph break that is more than MN_CKIN_MSG from the beginning.
101 */
102 #define MN_CKIN_MSG 100
103 #define MX_CKIN_MSG 300
104
105 /*
106 ** The following macros are used to cast pointers to integers and
107 ** integers to pointers. The way you do this varies from one compiler
108 ** to the next, so we have developed the following set of #if statements
109 ** to generate appropriate macros for a wide range of compilers.
110 **
111 ** The correct "ANSI" way to do this is to use the intptr_t type.
112 ** Unfortunately, that typedef is not available on all compilers, or
113 ** if it is available, it requires an #include of specific headers
114 ** that vary from one machine to the next.
115 */
116 #if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
117 # define FOSSIL_INT_TO_PTR(X) ((void*)(__PTRDIFF_TYPE__)(X))
118 # define FOSSIL_PTR_TO_INT(X) ((int)(__PTRDIFF_TYPE__)(X))
119 #elif !defined(__GNUC__) /* Works for compilers other than LLVM */
120 # define FOSSIL_INT_TO_PTR(X) ((void*)&((char*)0)[X])
121 # define FOSSIL_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0))
122 #else /* Generates a warning - but it always works */
123 # define FOSSIL_INT_TO_PTR(X) ((void*)(X))
124 # define FOSSIL_PTR_TO_INT(X) ((int)(X))
125 #endif
126
127
128 /* Unset the following to disable internationalization code. */
129 #ifndef FOSSIL_I18N
130 # define FOSSIL_I18N 1
131 #endif
132
+2 -1
--- src/th_lang.c
+++ src/th_lang.c
@@ -7,10 +7,11 @@
77
** declared in th.h, so this file serves as both a part of the language
88
** implementation and an example of how to extend the language with
99
** new commands.
1010
*/
1111
12
+#include "config.h"
1213
#include "th.h"
1314
#include <string.h>
1415
#include <assert.h>
1516
1617
int Th_WrongNumArgs(Th_Interp *interp, const char *zMsg){
@@ -571,11 +572,11 @@
571572
return Th_WrongNumArgs(interp, "return ?value?");
572573
}
573574
if( argc==2 ){
574575
Th_SetResult(interp, argv[1], argl[1]);
575576
}
576
- return (int)ctx;
577
+ return FOSSIL_PTR_TO_INT(ctx);
577578
}
578579
579580
/*
580581
** TH Syntax:
581582
**
582583
--- src/th_lang.c
+++ src/th_lang.c
@@ -7,10 +7,11 @@
7 ** declared in th.h, so this file serves as both a part of the language
8 ** implementation and an example of how to extend the language with
9 ** new commands.
10 */
11
 
12 #include "th.h"
13 #include <string.h>
14 #include <assert.h>
15
16 int Th_WrongNumArgs(Th_Interp *interp, const char *zMsg){
@@ -571,11 +572,11 @@
571 return Th_WrongNumArgs(interp, "return ?value?");
572 }
573 if( argc==2 ){
574 Th_SetResult(interp, argv[1], argl[1]);
575 }
576 return (int)ctx;
577 }
578
579 /*
580 ** TH Syntax:
581 **
582
--- src/th_lang.c
+++ src/th_lang.c
@@ -7,10 +7,11 @@
7 ** declared in th.h, so this file serves as both a part of the language
8 ** implementation and an example of how to extend the language with
9 ** new commands.
10 */
11
12 #include "config.h"
13 #include "th.h"
14 #include <string.h>
15 #include <assert.h>
16
17 int Th_WrongNumArgs(Th_Interp *interp, const char *zMsg){
@@ -571,11 +572,11 @@
572 return Th_WrongNumArgs(interp, "return ?value?");
573 }
574 if( argc==2 ){
575 Th_SetResult(interp, argv[1], argl[1]);
576 }
577 return FOSSIL_PTR_TO_INT(ctx);
578 }
579
580 /*
581 ** TH Syntax:
582 **
583

Keyboard Shortcuts

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