You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by dr...@apache.org on 2001/06/06 23:52:45 UTC

cvs commit: apr/shmem/beos shmem.c

dreid       01/06/06 14:52:45

  Modified:    shmem/beos shmem.c
  Log:
  Stop some compiler warnings on beos...
  
  Revision  Changes    Path
  1.2       +6 -6      apr/shmem/beos/shmem.c
  
  Index: shmem.c
  ===================================================================
  RCS file: /home/cvs/apr/shmem/beos/shmem.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- shmem.c	2001/04/30 20:55:17	1.1
  +++ shmem.c	2001/06/06 21:52:42	1.2
  @@ -57,6 +57,7 @@
   #include "apr_errno.h"
   #include "apr_lib.h"
   #include "apr_strings.h"
  +#include <stdio.h>
   #include <stdlib.h>
   #include <kernel/OS.h>
   
  @@ -80,7 +81,9 @@
   
   #define MIN_BLK_SIZE 128
   
  +/*
   #define DEBUG_ 1
  +*/
   
   void add_block(struct block_t **list, struct block_t *blk);
   void split_block(struct block_t **list, struct block_t *blk, apr_size_t size);
  @@ -204,7 +207,7 @@
   static void free_block(struct shmem_t *m, void *entity)
   {
       struct block_t *b;
  -    if (b = find_block_by_addr(m->uselist, entity)){
  +    if ((b = find_block_by_addr(m->uselist, entity))){
           remove_block(&(m->uselist), b);
           add_block(&(m->freelist), b);
           m->avail += b->size;
  @@ -236,11 +239,8 @@
   apr_status_t apr_shm_init(struct shmem_t **m, apr_size_t reqsize, const char *file, 
                             apr_pool_t *p)
   {
  -    int rc;
  -    int pages;
       apr_size_t pagesize;
       area_id newid;
  -    char *name = NULL;
       char *addr;
   
       (*m) = (struct shmem_t *)apr_pcalloc(p, sizeof(struct shmem_t));
  @@ -278,7 +278,7 @@
   void *apr_shm_malloc(struct shmem_t *m, apr_size_t reqsize)
   {
       struct block_t *b;
  -    if (b = alloc_block(m, reqsize))
  +    if ((b = alloc_block(m, reqsize)))
           return b->addr;
       return NULL;
   }
  @@ -286,7 +286,7 @@
   void *apr_shm_calloc(struct shmem_t *m, apr_size_t reqsize)
   {
       struct block_t *b; 
  -    if (b = alloc_block(m, reqsize)){  
  +    if ((b = alloc_block(m, reqsize))){  
           memset(b->addr, 0, reqsize);
           return b->addr;
       }
  
  
  

Re: cvs commit: apr/shmem/beos shmem.c

Posted by Greg Stein <gs...@lyra.org>.
On Wed, Jun 06, 2001 at 09:52:45PM -0000, dreid@apache.org wrote:
>...
>   --- shmem.c	2001/04/30 20:55:17	1.1
>   +++ shmem.c	2001/06/06 21:52:42	1.2
>   @@ -57,6 +57,7 @@
>    #include "apr_errno.h"
>    #include "apr_lib.h"
>    #include "apr_strings.h"
>   +#include <stdio.h>

What is stdio for? I wouldn't think that to be necessary here.

>...
>   @@ -204,7 +207,7 @@
>    static void free_block(struct shmem_t *m, void *entity)
>    {
>        struct block_t *b;
>   -    if (b = find_block_by_addr(m->uselist, entity)){
>   +    if ((b = find_block_by_addr(m->uselist, entity))){

This would be clearer to write:

  if ((b = ...) != NULL)

Just throwing in parens is likely to hit the case one day, where somebody
"optimizes" the parens out of there and we get the compiler warning again.
Or even worse, if somebody thinks it should be "b == ...". The "!= NULL"
makes it quite explicit what is needed / being-done.

>...
>   @@ -278,7 +278,7 @@
>    void *apr_shm_malloc(struct shmem_t *m, apr_size_t reqsize)
>    {
>        struct block_t *b;
>   -    if (b = alloc_block(m, reqsize))
>   +    if ((b = alloc_block(m, reqsize)))
>            return b->addr;
>        return NULL;
>    }
>   @@ -286,7 +286,7 @@
>    void *apr_shm_calloc(struct shmem_t *m, apr_size_t reqsize)
>    {
>        struct block_t *b; 
>   -    if (b = alloc_block(m, reqsize)){  
>   +    if ((b = alloc_block(m, reqsize))){  

Same comment for these.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/