Skip to content

Instantly share code, notes, and snippets.

@jonm
jonm / errors-after-comm-c.txt
Created October 3, 2015 21:19
make run after fixing initial compilation errors in comm.c
$ make
gcc -g -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -c -o comm.o comm.c
comm.c:163:25: warning: implicit declaration of function 'atoi' is invalid in C99 [-Wimplicit-function-declaration]
} else if ((port = atoi(argv[pos])) <= 1024) {
^
comm.c:163:8: warning: add explicit braces to avoid dangling else [-Wdangling-else]
} else if ((port = atoi(argv[pos])) <= 1024) {
^
comm.c:173:7: warning: implicit declaration of function 'chdir' is invalid in C99 [-Wimplicit-function-declaration]
if (chdir(dir) < 0) {
@jonm
jonm / ifdef-0-handler-c.txt
Created October 3, 2015 21:59
handler.c uses "#ifdef 0"
[~/src/SillyMUD/src]$ make
gcc -g -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -c -o handler.o handler.c
...
handler.c:203:8: error: macro names must be identifiers
#ifdef 0
^
...
21 warnings and 1 error generated.
make: *** [handler.o] Error 1
@jonm
jonm / wrong-args-to-malloc.txt
Created October 3, 2015 22:05
malloc called with the wrong number of arguments
[~/src/SillyMUD/src]$ make
gcc -g -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -c -o db.o db.c
...
db.c:3229:107: error: too many arguments to function call, expected 1, have 2
script_data[top_of_scripts].script = (struct foo_data *) malloc(script_data[top_of_scripts].script, sizeof(struct foo_data));
~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~
...
94 warnings and 1 error generated.
make: *** [db.o] Error 1
/* you really don't want to do a lot of reallocs all at once
*/
if (count==0) {
script_data[top_of_scripts].script = (struct foo_data *) malloc(script_data[top_of_scripts].script, sizeof(struct foo_data));
} else {
script_data[top_of_scripts].script = (struct foo_data *) realloc(script_data[top_of_scripts].script, sizeof(struct foo_data) * (count + 1));
}
/* This is an excerpt from a DikuMUD-derived codebase. DikuMUD was created by Sebastian Hammer, Michael Seifert</a>,
Hans Henrik Stærfeldt, Tom Madsen, and Katja Nyboe. This code is subject to the DikuMud License, as found at
@jonm
jonm / special-return-type.txt
Created October 4, 2015 01:04
the `special` function is missing a return value in one case
[~/src/SillyMUD/src]$ make
gcc -g -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -c -o interpreter.o interpreter.c
...
interpreter.c:450:5: error: non-void function 'special' should return a value [-Wreturn-type]
return;
^
...
16 warnings and 1 error generated.
make: *** [interpreter.o] Error 1
@jonm
jonm / special-function.c
Created October 4, 2015 01:13
the special function has an early return statement without a return value
int special(struct char_data *ch, int cmd, char *arg)
{
register struct obj_data *i;
register struct char_data *k;
int j;
if (ch->in_room == NOWHERE) {
char_to_room(ch, 3001);
return;
@jonm
jonm / include-malloc-h.txt
Created October 4, 2015 01:21
`utility.c` is trying to include `malloc.h`
[~/src/SillyMUD/src]$ make
gcc -g -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -c -o utility.o utility.c
utility.c:8:10: fatal error: 'malloc.h' file not found
#include <malloc.h>
^
1 error generated.
make: *** [utility.o] Error 1
@jonm
jonm / ifdef-0-utility-c.txt
Created October 4, 2015 01:29
`utility.c` also has an `#ifdef 0`
[~/src/SillyMUD/src]$ make
gcc -g -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -c -o utility.o utility.c
...
utility.c:879:8: error: macro names must be identifiers
#ifdef 0 /* removed 6/13, this was ridiculous */
^
...
12 warnings and 1 error generated.
make: *** [utility.o] Error 1
@jonm
jonm / shop-keeper-return-value.txt
Created October 4, 2015 01:34
the `shop_keeper` function is missing return values
[~/src/SillyMUD/src]$ make
gcc -g -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -c -o shop.o shop.c
...
shop.c:583:5: error: non-void function 'shop_keeper' should return a value
[-Wreturn-type]
return;
^
shop.c:588:5: error: non-void function 'shop_keeper' should return a value
[-Wreturn-type]
return;
@jonm
jonm / shop_keeper.c
Created October 4, 2015 01:40
the `shop_keeper` function from `shop.c` is missing some return values
int shop_keeper(struct char_data *ch, int cmd, char *arg, char *mob, int type)
{
char argm[100], buf[MAX_STRING_LENGTH];
struct char_data *temp_char;
struct char_data *keeper;
int shop_nr;
int citizen(struct char_data *ch, int cmd, char *arg, struct char_data *mob, int type);
if(type == EVENT_DWARVES_STRIKE) {