httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject [PATCH] table_do has improper prototype
Date Tue, 01 Apr 1997 08:35:32 GMT
table_do takes an int(*)(void *, char *, char *) but those should be const
char * otherwise it violates the abstraction of tables (i.e. would break
if we made them into hash_tables).  Also the casting of send_header_field
in http_protocol.c overrides C's (meagre) type-checking.

Roy, this makes send_header_field a static... whereas it looks like you
intended it to be useable outside http_protocol.c.  If you really want
that still then I'll let you cast... but I like code that diagnoses
itself as broken automatically and casting breaks that usually.  (If
gcc did common-tail-elimination then we could use a wrapper :)

Are there really broken compilers that require you to (void *)r when
passing to a prototyped void * parameter?

Dean

Index: alloc.c
===================================================================
RCS file: /export/home/cvs/apache/src/alloc.c,v
retrieving revision 1.25
diff -c -3 -r1.25 alloc.c
*** alloc.c	1997/03/22 23:51:01	1.25
--- alloc.c	1997/04/01 08:33:09
***************
*** 670,676 ****
   * Note that rec is simply passed-on to the comp function, so that the
   * caller can pass additional info for the task.
   */
! void table_do (int (*comp)(void *, char *, char *), void *rec, table *t, ...)
  {
      va_list vp;
      char *argp;
--- 670,677 ----
   * Note that rec is simply passed-on to the comp function, so that the
   * caller can pass additional info for the task.
   */
! void table_do (int (*comp)(void *, const char *, const char *), void *rec,
!     const table *t, ...)
  {
      va_list vp;
      char *argp;
Index: alloc.h
===================================================================
RCS file: /export/home/cvs/apache/src/alloc.h,v
retrieving revision 1.17
diff -c -3 -r1.17 alloc.h
*** alloc.h	1997/03/20 17:10:10	1.17
--- alloc.h	1997/04/01 08:33:09
***************
*** 149,155 ****
  void table_merge (table *, const char *name, const char *more_val);
  void table_unset (table *, const char *key);
  void table_add (table *, const char *name, const char *val);
! void table_do (int (*comp)(void *, char *, char *), void *rec, table *t, ...);
  
  table *overlay_tables (pool *p, const table *overlay, const table *base);     
  
--- 149,156 ----
  void table_merge (table *, const char *name, const char *more_val);
  void table_unset (table *, const char *key);
  void table_add (table *, const char *name, const char *val);
! void table_do (int (*comp)(void *, const char *, const char *), void *rec,
!     const table *t, ...);
  
  table *overlay_tables (pool *p, const table *overlay, const table *base);     
  
Index: http_protocol.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_protocol.c,v
retrieving revision 1.110
diff -c -3 -r1.110 http_protocol.c
*** http_protocol.c	1997/03/20 23:30:50	1.110
--- http_protocol.c	1997/04/01 08:33:09
***************
*** 1019,1026 ****
   * In other words, don't change this one without checking table_do in alloc.c.
   * It returns true unless there was a write error of some kind.
   */
! int send_header_field (request_rec *r, char *fieldname, char *fieldval)
  {
      return (0 < bvputs(r->connection->client,
                         fieldname, ": ", fieldval, "\015\012", NULL));
  }
--- 1019,1029 ----
   * In other words, don't change this one without checking table_do in alloc.c.
   * It returns true unless there was a write error of some kind.
   */
! static int send_header_field (void *vr, const char *fieldname,
!     const char *fieldval)
  {
+     request_rec *r = vr;
+ 
      return (0 < bvputs(r->connection->client,
                         fieldname, ": ", fieldval, "\015\012", NULL));
  }
***************
*** 1088,1095 ****
  
      rvputs( r, r->the_request, "\015\012", NULL );
  
!     table_do((int (*)(void *, char *, char *))send_header_field,
!              (void *)r, r->headers_in, NULL);
      bputs("\015\012", r->connection->client);
  
      kill_timeout(r);
--- 1091,1097 ----
  
      rvputs( r, r->the_request, "\015\012", NULL );
  
!     table_do(send_header_field, (void *)r, r->headers_in, NULL);
      bputs("\015\012", r->connection->client);
  
      kill_timeout(r);
***************
*** 1110,1117 ****
      table_set(r->headers_out, "Allow", make_allow(r));
      set_keepalive(r);
  
!     table_do((int (*)(void *, char *, char *))send_header_field,
!              (void *)r, r->headers_out, NULL);
      bputs("\015\012", r->connection->client);
  
      kill_timeout(r);
--- 1112,1118 ----
      table_set(r->headers_out, "Allow", make_allow(r));
      set_keepalive(r);
  
!     table_do(send_header_field, (void *)r, r->headers_out, NULL);
      bputs("\015\012", r->connection->client);
  
      kill_timeout(r);
***************
*** 1203,1210 ****
  
      /* Send the entire table of header fields, terminated by an empty line. */
  
!     table_do((int (*)(void *, char *, char *))send_header_field,
!              (void *)r, r->headers_out, NULL);
      bputs("\015\012", r->connection->client);
  
      kill_timeout(r);
--- 1204,1210 ----
  
      /* Send the entire table of header fields, terminated by an empty line. */
  
!     table_do(send_header_field, (void *)r, r->headers_out, NULL);
      bputs("\015\012", r->connection->client);
  
      kill_timeout(r);
***************
*** 1614,1621 ****
  	    basic_http_header(r);
  	    set_keepalive(r);
  
! 	    table_do((int (*)(void *, char *, char *))send_header_field,
! 	             (void *)r, r->headers_out,
  	             "Connection",
  	             "Keep-Alive",
  	             "ETag",
--- 1614,1620 ----
  	    basic_http_header(r);
  	    set_keepalive(r);
  
! 	    table_do(send_header_field, (void *)r, r->headers_out,
  	             "Connection",
  	             "Keep-Alive",
  	             "ETag",
Index: http_protocol.h
===================================================================
RCS file: /export/home/cvs/apache/src/http_protocol.h,v
retrieving revision 1.18
diff -c -3 -r1.18 http_protocol.h
*** http_protocol.h	1997/03/20 17:10:10	1.18
--- http_protocol.h	1997/04/01 08:33:10
***************
*** 59,68 ****
  
  request_rec *read_request (conn_rec *c);
  
- /* Send a single HTTP header field */
- 
- int send_header_field (request_rec *r, char *fieldname, char *fieldval);
- 
  /* Send the Status-Line and header fields for HTTP response */
  
  void send_http_header (request_rec *l);     
--- 59,64 ----


Mime
View raw message