Skip to content

Instantly share code, notes, and snippets.

jonm

Block or report user

Report or block jonm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jonm
jonm / ifdef-zero.txt
Created Oct 3, 2015
ifdef 0 is outdated, apparently
View ifdef-zero.txt
$ 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:771:8: error: macro names must be identifiers
#ifdef 0
^
...
@jonm
jonm / errors-after-comm-c.txt
Created Oct 3, 2015
make run after fixing initial compilation errors in comm.c
View errors-after-comm-c.txt
$ 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 Oct 3, 2015
handler.c uses "#ifdef 0"
View ifdef-0-handler-c.txt
[~/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 Oct 3, 2015
malloc called with the wrong number of arguments
View wrong-args-to-malloc.txt
[~/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
View db-c-bad-malloc.c
/* 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 / comm-c-Wreturn-type.c
Last active Oct 4, 2015
the `close_socket_fd` function
View comm-c-Wreturn-type.c
int close_socket_fd( int desc)
{
struct descriptor_data *d;
extern struct descriptor_data *descriptor_list;
for (d = descriptor_list;d;d=d->next) {
if (d->descriptor == desc) {
close_socket(d);
}
}
@jonm
jonm / special-return-type.txt
Created Oct 4, 2015
the `special` function is missing a return value in one case
View special-return-type.txt
[~/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 Oct 4, 2015
the special function has an early return statement without a return value
View special-function.c
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 Oct 4, 2015
`utility.c` is trying to include `malloc.h`
View include-malloc-h.txt
[~/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 Oct 4, 2015
`utility.c` also has an `#ifdef 0`
View ifdef-0-utility-c.txt
[~/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
You can’t perform that action at this time.