Skip to content
16 changes: 15 additions & 1 deletion centrallix-lib/src/mtask.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,10 @@ int
r_mtRun_PokeStack()
{
char buf[MT_MAX_STACK - MT_TASKSEP*2];
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
buf[0] = buf[0];
#pragma GCC diagnostic pop
return 0;
}

Expand All @@ -705,9 +708,15 @@ r_mtRun_Spacer()
** it needs to be in order for MTASK to work. DO NOT OPTIMIZE
** THIS MODULE!!!! The bogus assignment is added to keep gcc -Wall
** happy (and silent)....
**
** Edit (Israel): It wasn't very happy, so I added #pragma gcc directives
** to silence this warning when compiling.
**/
char buf[MT_TASKSEP];
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
buf[MT_TASKSEP-1] = buf[MT_TASKSEP-1];
#pragma GCC diagnostic pop

/*mprotect((char*)((int)(buf-MT_MAX_STACK+MT_TASKSEP*2+4095) & ~4095), MT_TASKSEP/2, PROT_NONE);*/
MTASK.CurrentThread->Stack = (unsigned char*)buf;
Expand All @@ -730,9 +739,15 @@ r_mtRunStartFn()
** it needs to be in order for MTASK to work. DO NOT OPTIMIZE
** THIS MODULE!!!! The bogus assignment is added to keep gcc -Wall
** happy.
**
** Edit (Israel): It wasn't very happy, so I added #pragma gcc directives
** to silence this warning when compiling.
**/
char buf[MT_MAX_STACK];
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
buf[MT_MAX_STACK-1] = buf[MT_MAX_STACK-1];
#pragma GCC diagnostic pop

/*if (r_newidx < 0) return 0;*/
if (--r_newidx) r_mtRunStartFn();
Expand Down Expand Up @@ -4265,4 +4280,3 @@ syGetSem(pSemaphore sem, int cnt, int flags)

return code;
}

2 changes: 1 addition & 1 deletion centrallix-lib/src/qprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ qpf_internal_hexdecode(pQPSession s, const char* src, size_t src_size, char** ds
char* cursor;
int ix;
int req_size;
char* orig_src = src;
const char* orig_src = src;

/** Required size **/
if (src_size%2 == 1)
Expand Down
3 changes: 1 addition & 2 deletions centrallix-lib/tests/test_00baseline.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ test(char** tname)
{
int i;
int iter;
int array[2];
int array[2] = {0};

*tname = "BASELINE - should pass";
iter = 1000*1000*300;
for(i=0;i<iter;i++) array[0] = array[1];

return iter;
}

4 changes: 0 additions & 4 deletions centrallix-lib/tests/test_02baseline.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
long long
test(char** tname)
{
int iter;

*tname = "BASELINE failed, return value - should fail";
iter = 1000*1000*1000;

return -1;
}

3 changes: 1 addition & 2 deletions centrallix-lib/tests/test_03baseline.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ long long
test(char** tname)
{
int iter;
int array[2];
int array[2] = {0};

*tname = "BASELINE sigsegv (11) caused - should crash";
iter = 1000*1000*1000;
*((int*)0) = array[1];

return iter;
}

2 changes: 0 additions & 2 deletions centrallix-lib/tests/test_mtlexer_07.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ test(char** tname)
int j;
int k;
int t;
int n;
int iter;
int flags;
pLxSession lxs;
Expand Down Expand Up @@ -63,4 +62,3 @@ test(char** tname)

return iter * n_tokens * n_iter;
}

2 changes: 0 additions & 2 deletions centrallix-lib/tests/test_mtlexer_15.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ test(char** tname)
int flagtypes[5] = { MLX_F_CPPCOMM, MLX_F_POUNDCOMM, MLX_F_SEMICOMM, MLX_F_DASHCOMM, MLX_F_CCOMM };
int n_flagtypes = 5;
int flags;
char* commnames[5] = { "cppcomm", "poundcomm", "semicomm", "dashcomm", "ccomm" };
pLxSession lxs;
pFile fd;

Expand Down Expand Up @@ -54,4 +53,3 @@ test(char** tname)

return iter * 10;
}

2 changes: 0 additions & 2 deletions centrallix-lib/tests/test_mtlexer_16.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ test(char** tname)
int flagtypes[5] = { MLX_F_CPPCOMM, MLX_F_POUNDCOMM, MLX_F_SEMICOMM, MLX_F_DASHCOMM, MLX_F_CCOMM };
int n_flagtypes = 5;
int flags;
char* commnames[5] = { "cppcomm", "poundcomm", "semicomm", "dashcomm", "ccomm" };
pLxSession lxs;
pFile fd;

Expand Down Expand Up @@ -54,4 +53,3 @@ test(char** tname)

return iter * 10;
}

11 changes: 5 additions & 6 deletions centrallix-lib/tests/test_qprintf_00.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ test(char** tname)
buf[2] = '\0';
buf[1] = 0xff;
buf[0] = '\0';
snprintf(buf+4, 36, "this is a string non-overflow test.");
snprintf(buf+4, 36, "this is a string non-overflow test.");
snprintf(buf+4, 36, "this is a string non-overflow test.");
snprintf(buf+4, 36, "this is a string non-overflow test.");
assert(!strcmp(buf+4,"this is a string non-overflow test."));
snprintf((char*)buf+4, 36, "this is a string non-overflow test.");
snprintf((char*)buf+4, 36, "this is a string non-overflow test.");
snprintf((char*)buf+4, 36, "this is a string non-overflow test.");
snprintf((char*)buf+4, 36, "this is a string non-overflow test.");
assert(!strcmp((char*)buf+4,"this is a string non-overflow test."));
assert(buf[43] == '\n');
assert(buf[42] == '\0');
assert(buf[41] == 0xff);
Expand All @@ -44,4 +44,3 @@ test(char** tname)

return iter*4;
}

11 changes: 5 additions & 6 deletions centrallix-lib/tests/test_qprintf_01.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ test(char** tname)
buf[2] = '\0';
buf[1] = 0xff;
buf[0] = '\0';
qpfPrintf(NULL, buf+4, 36, "this is a string non-overflow test.");
qpfPrintf(NULL, buf+4, 36, "this is a string non-overflow test.");
qpfPrintf(NULL, buf+4, 36, "this is a string non-overflow test.");
qpfPrintf(NULL, buf+4, 36, "this is a string non-overflow test.");
assert(!strcmp(buf+4,"this is a string non-overflow test."));
qpfPrintf(NULL, (char*)buf+4, 36, "this is a string non-overflow test.");
qpfPrintf(NULL, (char*)buf+4, 36, "this is a string non-overflow test.");
qpfPrintf(NULL, (char*)buf+4, 36, "this is a string non-overflow test.");
qpfPrintf(NULL, (char*)buf+4, 36, "this is a string non-overflow test.");
assert(!strcmp((char*)buf+4,"this is a string non-overflow test."));
assert(buf[43] == '\n');
assert(buf[42] == '\0');
assert(buf[41] == 0xff);
Expand All @@ -44,4 +44,3 @@ test(char** tname)

return iter*4;
}

11 changes: 5 additions & 6 deletions centrallix-lib/tests/test_qprintf_02.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ test(char** tname)
buf[2] = '\0';
buf[1] = 0xff;
buf[0] = '\0';
qpfPrintf(NULL, buf+4, 36, "this is a string non-overflow test.... NOT!");
qpfPrintf(NULL, buf+4, 36, "this is a string non-overflow test.... NOT!");
qpfPrintf(NULL, buf+4, 36, "this is a string non-overflow test.... NOT!");
qpfPrintf(NULL, buf+4, 36, "this is a string non-overflow test.... NOT!");
assert(!strcmp(buf+4,"this is a string non-overflow test."));
qpfPrintf(NULL, (char*)buf+4, 36, "this is a string non-overflow test.... NOT!");
qpfPrintf(NULL, (char*)buf+4, 36, "this is a string non-overflow test.... NOT!");
qpfPrintf(NULL, (char*)buf+4, 36, "this is a string non-overflow test.... NOT!");
qpfPrintf(NULL, (char*)buf+4, 36, "this is a string non-overflow test.... NOT!");
assert(!strcmp((char*)buf+4,"this is a string non-overflow test."));
assert(buf[43] == '\n');
assert(buf[42] == '\0');
assert(buf[41] == 0xff);
Expand All @@ -44,4 +44,3 @@ test(char** tname)

return iter*4;
}

11 changes: 5 additions & 6 deletions centrallix-lib/tests/test_qprintf_03.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ test(char** tname)
buf[2] = '\0';
buf[1] = 0xff;
buf[0] = '\0';
qpfPrintf(NULL, buf+4, 36, "this is a string non-overflow test.?");
qpfPrintf(NULL, buf+4, 36, "this is a string non-overflow test.?");
qpfPrintf(NULL, buf+4, 36, "this is a string non-overflow test.?");
qpfPrintf(NULL, buf+4, 36, "this is a string non-overflow test.?");
assert(!strcmp(buf+4,"this is a string non-overflow test."));
qpfPrintf(NULL, (char*)buf+4, 36, "this is a string non-overflow test.?");
qpfPrintf(NULL, (char*)buf+4, 36, "this is a string non-overflow test.?");
qpfPrintf(NULL, (char*)buf+4, 36, "this is a string non-overflow test.?");
qpfPrintf(NULL, (char*)buf+4, 36, "this is a string non-overflow test.?");
assert(!strcmp((char*)buf+4,"this is a string non-overflow test."));
assert(buf[43] == '\n');
assert(buf[42] == '\0');
assert(buf[41] == 0xff);
Expand All @@ -44,4 +44,3 @@ test(char** tname)

return iter*4;
}

11 changes: 5 additions & 6 deletions centrallix-lib/tests/test_qprintf_04.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ test(char** tname)
buf[2] = '\0';
buf[1] = 0xff;
buf[0] = '\0';
qpfPrintf(NULL, buf+4, 36, "");
qpfPrintf(NULL, buf+4, 36, "");
qpfPrintf(NULL, buf+4, 36, "");
qpfPrintf(NULL, buf+4, 36, "");
assert(!strcmp(buf+4,""));
qpfPrintf(NULL, (char*)buf+4, 36, "");
qpfPrintf(NULL, (char*)buf+4, 36, "");
qpfPrintf(NULL, (char*)buf+4, 36, "");
qpfPrintf(NULL, (char*)buf+4, 36, "");
assert(!strcmp((char*)buf+4,""));
assert(buf[43] == '\n');
assert(buf[42] == '\0');
assert(buf[41] == 0xff);
Expand All @@ -46,4 +46,3 @@ test(char** tname)

return iter*4;
}

9 changes: 4 additions & 5 deletions centrallix-lib/tests/test_qprintf_05.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ test(char** tname)
buf[2] = '\0';
buf[1] = 0xff;
buf[0] = '\0';
qpfPrintf(NULL, buf+4, 0, "this is a string overflow test.");
qpfPrintf(NULL, buf+4, 0, "this is a string overflow test.");
qpfPrintf(NULL, buf+4, 0, "this is a string overflow test.");
qpfPrintf(NULL, buf+4, 0, "this is a string overflow test.");
qpfPrintf(NULL, (char*)buf+4, 0, "this is a string overflow test.");
qpfPrintf(NULL, (char*)buf+4, 0, "this is a string overflow test.");
qpfPrintf(NULL, (char*)buf+4, 0, "this is a string overflow test.");
qpfPrintf(NULL, (char*)buf+4, 0, "this is a string overflow test.");
assert(buf[43] == '\n');
assert(buf[42] == '\0');
assert(buf[41] == 0xff);
Expand All @@ -47,4 +47,3 @@ test(char** tname)

return iter*4;
}

11 changes: 5 additions & 6 deletions centrallix-lib/tests/test_qprintf_06.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ test(char** tname)
buf[2] = '\0';
buf[1] = 0xff;
buf[0] = '\0';
qpfPrintf(NULL, buf+4, 1, "this is a string overflow test.");
qpfPrintf(NULL, buf+4, 1, "this is a string overflow test.");
qpfPrintf(NULL, buf+4, 1, "this is a string overflow test.");
qpfPrintf(NULL, buf+4, 1, "this is a string overflow test.");
assert(!strcmp(buf+4, ""));
qpfPrintf(NULL, (char*)buf+4, 1, "this is a string overflow test.");
qpfPrintf(NULL, (char*)buf+4, 1, "this is a string overflow test.");
qpfPrintf(NULL, (char*)buf+4, 1, "this is a string overflow test.");
qpfPrintf(NULL, (char*)buf+4, 1, "this is a string overflow test.");
assert(!strcmp((char*)buf+4, ""));
assert(buf[43] == '\n');
assert(buf[42] == '\0');
assert(buf[41] == 0xff);
Expand All @@ -48,4 +48,3 @@ test(char** tname)

return iter*4;
}

11 changes: 5 additions & 6 deletions centrallix-lib/tests/test_qprintf_07.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ test(char** tname)
buf[2] = '\0';
buf[1] = 0xff;
buf[0] = '\0';
qpfPrintf(NULL, buf+4, 36, "The word %STR is our data.", "STRING");
qpfPrintf(NULL, buf+4, 36, "The word %STR is our data.", "STRING");
qpfPrintf(NULL, buf+4, 36, "The word %STR is our data.", "STRING");
rval = qpfPrintf(NULL, buf+4, 36, "The word %STR is our data.", "STRING");
assert(!strcmp(buf+4, "The word STRING is our data."));
qpfPrintf(NULL, (char*)buf+4, 36, "The word %STR is our data.", "STRING");
qpfPrintf(NULL, (char*)buf+4, 36, "The word %STR is our data.", "STRING");
qpfPrintf(NULL, (char*)buf+4, 36, "The word %STR is our data.", "STRING");
rval = qpfPrintf(NULL, (char*)buf+4, 36, "The word %STR is our data.", "STRING");
assert(!strcmp((char*)buf+4, "The word STRING is our data."));
assert(rval == 28);
assert(buf[43] == '\n');
assert(buf[42] == '\0');
Expand All @@ -43,4 +43,3 @@ test(char** tname)

return iter*4;
}

11 changes: 5 additions & 6 deletions centrallix-lib/tests/test_qprintf_08.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ test(char** tname)
buf[2] = '\0';
buf[1] = 0xff;
buf[0] = '\0';
qpfPrintf(NULL, buf+4, 36, "This is our data: %STR", "STRING");
qpfPrintf(NULL, buf+4, 36, "This is our data: %STR", "STRING");
qpfPrintf(NULL, buf+4, 36, "This is our data: %STR", "STRING");
rval = qpfPrintf(NULL, buf+4, 36, "This is our data: %STR", "STRING");
assert(!strcmp(buf+4, "This is our data: STRING"));
qpfPrintf(NULL, (char*)buf+4, 36, "This is our data: %STR", "STRING");
qpfPrintf(NULL, (char*)buf+4, 36, "This is our data: %STR", "STRING");
qpfPrintf(NULL, (char*)buf+4, 36, "This is our data: %STR", "STRING");
rval = qpfPrintf(NULL, (char*)buf+4, 36, "This is our data: %STR", "STRING");
assert(!strcmp((char*)buf+4, "This is our data: STRING"));
assert(rval == 24);
assert(buf[43] == '\n');
assert(buf[42] == '\0');
Expand All @@ -43,4 +43,3 @@ test(char** tname)

return iter*4;
}

11 changes: 5 additions & 6 deletions centrallix-lib/tests/test_qprintf_09.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ test(char** tname)
buf[2] = '\0';
buf[1] = 0xff;
buf[0] = '\0';
qpfPrintf(NULL, buf+4, 36, "%STR is our data today.", "STRING");
qpfPrintf(NULL, buf+4, 36, "%STR is our data today.", "STRING");
qpfPrintf(NULL, buf+4, 36, "%STR is our data today.", "STRING");
rval = qpfPrintf(NULL, buf+4, 36, "%STR is our data today.", "STRING");
assert(!strcmp(buf+4, "STRING is our data today."));
qpfPrintf(NULL, (char*)buf+4, 36, "%STR is our data today.", "STRING");
qpfPrintf(NULL, (char*)buf+4, 36, "%STR is our data today.", "STRING");
qpfPrintf(NULL, (char*)buf+4, 36, "%STR is our data today.", "STRING");
rval = qpfPrintf(NULL, (char*)buf+4, 36, "%STR is our data today.", "STRING");
assert(!strcmp((char*)buf+4, "STRING is our data today."));
assert(rval == 25);
assert(buf[43] == '\n');
assert(buf[42] == '\0');
Expand All @@ -43,4 +43,3 @@ test(char** tname)

return iter*4;
}

11 changes: 5 additions & 6 deletions centrallix-lib/tests/test_qprintf_10.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ test(char** tname)
buf[2] = '\0';
buf[1] = 0xff;
buf[0] = '\0';
snprintf(buf+4, 36, "The word %s is our data.", "STRING");
snprintf(buf+4, 36, "The word %s is our data.", "STRING");
snprintf(buf+4, 36, "The word %s is our data.", "STRING");
rval = snprintf(buf+4, 36, "The word %s is our data.", "STRING");
assert(!strcmp(buf+4,"The word STRING is our data."));
snprintf((char*)buf+4, 36, "The word %s is our data.", "STRING");
snprintf((char*)buf+4, 36, "The word %s is our data.", "STRING");
snprintf((char*)buf+4, 36, "The word %s is our data.", "STRING");
rval = snprintf((char*)buf+4, 36, "The word %s is our data.", "STRING");
assert(!strcmp((char*)buf+4,"The word STRING is our data."));
assert(rval == 28);
assert(buf[43] == '\n');
assert(buf[42] == '\0');
Expand All @@ -43,4 +43,3 @@ test(char** tname)

return iter*4;
}

11 changes: 5 additions & 6 deletions centrallix-lib/tests/test_qprintf_11.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ test(char** tname)
buf[2] = '\0';
buf[1] = 0xff;
buf[0] = '\0';
qpfPrintf(NULL, buf+4, 36, "The word %STR is our data... this is an overflow", "STRING");
qpfPrintf(NULL, buf+4, 36, "The word %STR is our data... this is an overflow", "STRING");
qpfPrintf(NULL, buf+4, 36, "The word %STR is our data... this is an overflow", "STRING");
rval = qpfPrintf(NULL, buf+4, 36, "The word %STR is our data... this is an overflow", "STRING");
assert(!strcmp(buf+4, "The word STRING is our data... this"));
qpfPrintf(NULL, (char*)buf+4, 36, "The word %STR is our data... this is an overflow", "STRING");
qpfPrintf(NULL, (char*)buf+4, 36, "The word %STR is our data... this is an overflow", "STRING");
qpfPrintf(NULL, (char*)buf+4, 36, "The word %STR is our data... this is an overflow", "STRING");
rval = qpfPrintf(NULL, (char*)buf+4, 36, "The word %STR is our data... this is an overflow", "STRING");
assert(!strcmp((char*)buf+4, "The word STRING is our data... this"));
assert(rval == 50);
assert(buf[43] == '\n');
assert(buf[42] == '\0');
Expand All @@ -43,4 +43,3 @@ test(char** tname)

return iter*4;
}

Loading