Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove asserts that generate compiler warnings #1533

Merged
merged 1 commit into from
May 21, 2024

Conversation

linas
Copy link
Member

@linas linas commented May 21, 2024

This fixes issue #1508.
Also some minor style modernizations included.

This fixes issue opencog#1508.
Also some minor style modernizations included.
@ampli
Copy link
Member

ampli commented May 23, 2024

Two lines remained in print.c (365, 438):

assert (ppla[link].lw != SIZE_MAX, "Missing word in link");
if ((j%7 == 0) && (j>0)) dyn_strcat(string,"\n");
j++;
append_string(string,"[%d %d %d",
ppla[link].lw - d, ppla[link].rw - d,
pctx->link_heights[link]);
append_string(string," (%s)]", ppla[link].link_name);
}
dyn_strcat(string,"]");
dyn_strcat(string,"\n");
dyn_strcat(string,"[");
for (j=0; j < pctx->N_rows; j++)
{
if (j>0) append_string(string, " %d", pctx->row_starts[j]);
else append_string(string,"%d", pctx->row_starts[j]);
}
dyn_strcat(string,"]\n");
return dyn_str_take(string);
}
#define HEIGHT_INC 10
static void diagram_alloc_tmpmem(size_t **start, char ***pic, char ***xpic,
size_t *cur_height, size_t max_height,
size_t max_bytes, size_t num_cols)
{
assert(num_cols <= max_bytes, "Columns overflow");
assert(max_height > *cur_height, "New diagram height is too small");
*start = realloc(*start, max_height * sizeof(size_t));
*pic = realloc(*pic, max_height * sizeof(char *));
*xpic = realloc(*xpic, max_height * sizeof(char *));
for (size_t i = *cur_height; i < max_height; i++)
{
/* Allocate memory for both pic and xpic. */
char *picmem = malloc(max_bytes * 2 + 2);
(*pic)[i] = picmem;
(*xpic)[i] = picmem + max_bytes;
memset((*pic)[i], ' ', num_cols);
(*pic)[i][num_cols] = '\0';
}
*cur_height = max_height;
}
typedef struct
{
Link *lnk;
unsigned int len; /* Length of this link */
} link_by_length;
static int by_link_len(const void *a, const void *b)
{
const link_by_length * const *la = a;
const link_by_length * const *lb = b;
return (*la)->len - (*lb)->len;
}
static void sort_link_lengths(Link *ppla, link_by_length *ll,
unsigned int N_links)
{
link_by_length *ll_tmp = alloca(N_links * sizeof(*ll_tmp));
link_by_length **lla = alloca(N_links * sizeof(*lla));
for (unsigned int j = 0; j < N_links; j++)
{
Link *lnk = &ppla[j];
assert(lnk->lw != SIZE_MAX, "Missing word in link");

linas added a commit that referenced this pull request May 25, 2024
Missed two asserts that should hve been done in #1533 #1508
@linas
Copy link
Member Author

linas commented May 25, 2024

Dohh. Thanks. Fixed this in direct push of 6f6180d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants