Skip to content

Commit

Permalink
pcu: assert -> PCU_ALWAYS_ASSERT
Browse files Browse the repository at this point in the history
  • Loading branch information
bgranzow committed Mar 8, 2017
1 parent f27f64f commit dba270e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
5 changes: 3 additions & 2 deletions pcu/pcu_aa.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
*/

#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include "pcu_util.h"
#include "pcu_aa.h"

static pcu_aa_node pcu_aa_bottom =
Expand Down Expand Up @@ -99,7 +100,7 @@ struct remove_vars

static void remove_successor(pcu_aa_tree* t, struct remove_vars* v)
{
assert(*t);
PCU_ALWAYS_ASSERT(*t);
if (*t != &pcu_aa_bottom)
{ /* search down the tree and set pointers last and deleted */
v->last = *t;
Expand Down
16 changes: 8 additions & 8 deletions pcu/pcu_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "pcu_util.h"
#include <sys/types.h>
#include <limits.h>

Expand Down Expand Up @@ -70,20 +70,20 @@ static void compressed_read(pcu_file* pf, void* data, size_t size)
int bzerror;
int len;
int rv;
assert(size < INT_MAX);
PCU_ALWAYS_ASSERT(size < INT_MAX);
len = size;
rv = BZ2_bzRead(&bzerror, pf->bzf, data, len);
if (bzerror != BZ_OK && bzerror != BZ_STREAM_END)
reel_fail("BZ2_bzRead failed with code %d", bzerror);
assert(rv == len);
PCU_ALWAYS_ASSERT(rv == len);
}

static void compressed_write(pcu_file* pf, void const* data, size_t size)
{
int bzerror;
int len;
void* bzip2_is_not_const_correct;
assert(size < INT_MAX);
PCU_ALWAYS_ASSERT(size < INT_MAX);
len = size;
bzip2_is_not_const_correct = (void*)data;
BZ2_bzWrite(&bzerror, pf->bzf, bzip2_is_not_const_correct, len);
Expand Down Expand Up @@ -272,14 +272,14 @@ static void pcu_swap_64(uint32_t* p)

void pcu_swap_unsigneds(unsigned* p, size_t n)
{
assert(sizeof(unsigned)==4);
PCU_ALWAYS_ASSERT(sizeof(unsigned)==4);
for (size_t i=0; i < n; ++i)
pcu_swap_32(p++);
}

void pcu_swap_doubles(double* p, size_t n)
{
assert(sizeof(double)==8);
PCU_ALWAYS_ASSERT(sizeof(double)==8);
for (size_t i=0; i < n; ++i)
pcu_swap_64((uint32_t*)(p++));
}
Expand All @@ -288,7 +288,7 @@ void pcu_write_unsigneds(pcu_file* f, unsigned* p, size_t n)
{
unsigned* tmp;
if (n)
assert(p != 0);
PCU_ALWAYS_ASSERT(p != 0);
if (PCU_ENDIANNESS != PCU_ENCODED_ENDIAN) {
tmp = malloc(n * sizeof(unsigned));
memcpy(tmp, p, n * sizeof(unsigned));
Expand All @@ -304,7 +304,7 @@ void pcu_write_doubles(pcu_file* f, double* p, size_t n)
{
double* tmp;
if (n)
assert(p != 0);
PCU_ALWAYS_ASSERT(p != 0);
if (PCU_ENDIANNESS != PCU_ENCODED_ENDIAN) {
tmp = malloc(n * sizeof(double));
memcpy(tmp, p, n * sizeof(double));
Expand Down
7 changes: 4 additions & 3 deletions pcu/pcu_mpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
BSD license as described in the LICENSE file in the top-level directory.
*******************************************************************************/
#include <stdio.h>
#include "pcu_mpi.h"
#include <assert.h>
#include "pcu_util.h"

static pcu_mpi* global_mpi;

Expand Down Expand Up @@ -45,8 +46,8 @@ int pcu_mpi_rank(void)
static void check_rank(int rank)
{
(void)rank;
assert(0 <= rank);
assert(rank < pcu_mpi_size());
PCU_ALWAYS_ASSERT(0 <= rank);
PCU_ALWAYS_ASSERT(rank < pcu_mpi_size());
}

void pcu_mpi_send(pcu_message* m, MPI_Comm comm)
Expand Down
2 changes: 1 addition & 1 deletion pcu/pcu_order.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "pcu_aa.h"
#include "pcu_msg.h"
#include "noto_malloc.h"
#include <assert.h>
#include "pcu_util.h"

struct message {
pcu_aa_node node;
Expand Down

0 comments on commit dba270e

Please sign in to comment.