Pesky warnings

Posted by Thrashmodule on Wed 28 Nov 2007 01:00 AM — 19 posts, 80,333 views.

USA #0
Hello all I'm new here and was wondering if someone could help me clean up my make a little I'm on Win XP running Cygwin (crypt loaded) and I'm using EmberMUD v. 0.9.45 found here http://www.mudmagic.com/codes/download/diku/merc/rom/ember

here is a snapshot of my make:


$ make
gcc -c -Wall -ggdb -O3 -DLINUX  act_comm.c
gcc -c -Wall -ggdb -O3 -DLINUX  act_info.c
act_info.c: In function `do_password':
act_info.c:3704: warning: implicit declaration of function `crypt'
act_info.c:3704: warning: passing arg 1 of `strcmp' makes pointer from integer w
ithout a cast
act_info.c:3721: warning: assignment makes pointer from integer without a cast
gcc -c -Wall -ggdb -O3 -DLINUX  act_move.c
gcc -c -Wall -ggdb -O3 -DLINUX  act_obj.c
gcc -c -Wall -ggdb -O3 -DLINUX  act_wiz.c
gcc -c -Wall -ggdb -O3 -DLINUX  auction.c
gcc -c -Wall -ggdb -O3 -DLINUX  ban.c
gcc -c -Wall -ggdb -O3 -DLINUX  bank.c
gcc -c -Wall -ggdb -O3 -DLINUX  bit.c
gcc -c -Wall -ggdb -O3 -DLINUX  board.c
gcc -c -Wall -ggdb -O3 -DLINUX  comm.c
comm.c: In function `nanny':
comm.c:1749: warning: implicit declaration of function `crypt'
comm.c:1749: warning: passing arg 1 of `strcmp' makes pointer from integer witho
ut a cast
comm.c:1886: warning: assignment makes pointer from integer without a cast
comm.c:1907: warning: passing arg 1 of `strcmp' makes pointer from integer witho
ut a cast
gcc -c -Wall -ggdb -O3 -DLINUX  const.c
gcc -c -Wall -ggdb -O3 -DLINUX  clan.c
gcc -c -Wall -ggdb -O3 -DLINUX  class.c
gcc -c -Wall -ggdb -O3 -DLINUX  db.c
gcc -c -Wall -ggdb -O3 -DLINUX  factions.c
gcc -c -Wall -ggdb -O3 -DLINUX  fight.c
gcc -c -Wall -ggdb -O3 -DLINUX  handler.c
gcc -c -Wall -ggdb -O3 -DLINUX  helpolc.c
gcc -c -Wall -ggdb -O3 -DLINUX  interp.c
gcc -c -Wall -ggdb -O3 -DLINUX  magic.c
magic.c: In function `spell_locate_object':
magic.c:3398: warning: the address of `can_see', will always evaluate as `true'
gcc -c -Wall -ggdb -O3 -DLINUX  marry.c
gcc -c -Wall -ggdb -O3 -DLINUX  mem.c
gcc -c -Wall -ggdb -O3 -DLINUX  mprog_commands.c
gcc -c -Wall -ggdb -O3 -DLINUX  mprog_procs.c
gcc -c -Wall -ggdb -O3 -DLINUX  mud_progs.c
gcc -c -Wall -ggdb -O3 -DLINUX  olc.c
gcc -c -Wall -ggdb -O3 -DLINUX  olc_act.c
gcc -c -Wall -ggdb -O3 -DLINUX  olc_save.c
gcc -c -Wall -ggdb -O3 -DLINUX  newbits.c
gcc -c -Wall -ggdb -O3 -DLINUX  pty.c
gcc -c -Wall -ggdb -O3 -DLINUX  random.c
gcc -c -Wall -ggdb -O3 -DLINUX  recycle.c
gcc -c -Wall -ggdb -O3 -DLINUX  route_io.c
gcc -c -Wall -ggdb -O3 -DLINUX  save.c
gcc -c -Wall -ggdb -O3 -DLINUX  skills.c
gcc -c -Wall -ggdb -O3 -DLINUX  socialolc.c
gcc -c -Wall -ggdb -O3 -DLINUX  ssm.c
gcc -c -Wall -ggdb -O3 -DLINUX  string.c
gcc -c -Wall -ggdb -O3 -DLINUX  todoolc.c
gcc -c -Wall -ggdb -O3 -DLINUX  update.c
rm -f ember
gcc -O2 -DLINUX -o ember act_comm.o     act_info.o      act_move.o act_obj.oact_
wiz.o   auction.o ban.o         bank.o          bit.o board.o   comm.o  const.o
clan.o  class.o         db.o factions.o fight.o         handler.o helpolc.ointer
p.o     magic.o marry.o mem.o           mprog_commands.o mprog_procs.o  mud_prog
s.o     olc.o olc_act.o olc_save.o      newbits.o pty.o         random.orecycle.
o route_io.o    save.o          skills.o socialolc.o    ssm.o           string.o
 todoolc.o      update.o -lm -lcrypt


-----------------------------------------------------------

and a look at my makefile:


CC      = gcc
PROF    = -DLINUX
NOCRYPT = 
C_FLAGS = -Wall -ggdb -O3 $(PROF) $(NOCRYPT)
L_FLAGS = -O2 $(PROF)

O_FILES = act_comm.o	act_info.o	act_move.o \
          act_obj.o	act_wiz.o	auction.o \
          ban.o		bank.o		bit.o \
          board.o	comm.o		const.o \
          clan.o	class.o		db.o \
          factions.o	fight.o		handler.o \
          helpolc.o	interp.o	magic.o \
          marry.o	mem.o		mprog_commands.o \
          mprog_procs.o	mud_progs.o	olc.o \
          olc_act.o	olc_save.o	newbits.o \
          pty.o		random.o	recycle.o \
          route_io.o	save.o		skills.o \
          socialolc.o	ssm.o		string.o \
          todoolc.o	update.o

all: ember

ember: $(O_FILES)
	rm -f ember
	$(CC) $(L_FLAGS) -o ember $(O_FILES) -lm -lcrypt

.c.o: merc.h
	$(CC) -c $(C_FLAGS) $<

clean:
	-rm -f *.o *~ Ember.patch *.orig *.rej \#*

distclean:
	-rm -f ../area/*~ ../area/*.txt
	-rm -f ../src/*~ ../*~
	-rm -f ../gods/* ../log/* ../player/*

src:
	-rm -f src.tar.gz
	-tar -czvf src.tar.gz Makefile *.c *.h

diff: clean
	@clear
	@echo Diffing against ./original directory and creating Ember.patch.
	@echo Ignore the following error.
	@echo  
	@diff -c -P -N -x ember -x core -x Ember.patch ./original ./ > ./Ember.patch

update:
	rm -f orignial/*
	cp *.c *.h Makefile startup* original


also on a side note ..... I cnat see anything after i type ./startup i just get a blinking cursor and a locked up shell if i start another cygwin i can use ps and see the mud is running and i can log on but i get no messages about the muds status or people logging nothing at all any help would be appricated thank you for your time
USA #1
Well you ran the MUD just fine. The warnings are warnings, not errors.

Quote:
i can log on but i get no messages about the muds status or people logging nothing at all any help would be appricated thank you for your time

What are you expecting to see?
USA #2
I was hoping to find out why I have warnings at all call me a bit of a perfectionist :D

and i was hoping to see something like:
Tue Nov 27 18:26:53 2007 :: ROM is ready to rock on port 5500.
Tue Nov 27 18:27:46 2007 :: Sock.sinaddr: 0.0.0.0
Tue Nov 27 18:27:55 2007 :: Loading Goober.
Tue Nov 27 18:27:56 2007 :: Goober@0.0.0.0 has connected.
Tue Nov 27 18:28:12 2007 :: Goober has quit.
as i do with the windows port of ROM24 it's been a long long time since i ran a mud but i seem to remember that being pretty standard output not a blinking cursor and a locked shell.
Amended on Wed 28 Nov 2007 10:24 PM by Thrashmodule
USA #3
Those logs depend on the MUD. Some MUDs may log to the Imm, some may not. Perhaps you don't have the log channel on. I'm not sure, I've never used that codebase.

For the crypt warnings, do a search on this forum. You'll get plenty of results.
USA #4
Could you paste the lines corresponding to this warning:

act_info.c:3704: warning: passing arg 1 of `strcmp' makes pointer from integer without a cast
act_info.c:3721: warning: assignment makes pointer from integer without a cast

Chances are most of those warnings are from the same kind of problem.

And then this one:
magic.c: In function `spell_locate_object':
magic.c:3398: warning: the address of `can_see', will always evaluate as `true'


Without seeing the exact line it's hard to know what exactly is wrong. :-)
USA #5

line 3704 act_info.c


    if ( strcmp( crypt( arg, ch->pcdata->pwd ), ch->pcdata->pwd ) )


here is line 3721


    pwdnew = crypt( arg2, ch->name );




and here is 1749 of comm.c


if ( strcmp( crypt( argument, ch->pcdata->pwd ), ch->pcdata->pwd ) )


and 1886


pwdnew = crypt( argument, ch->name );


and 1907


if ( strcmp( crypt( argument, ch->pcdata->pwd ), ch->pcdata->pwd ) )


the problem i am having understanding is they all seem to revolve around crypt but i have crypt installed in cygwin trust me i did search because at first i had the undefined error which cleared when crypt was added to cygwin now i just get the warning and i don't get why.



ok as for the odd man out warning.
line 3398 of magic.c


 if ( in_obj->carried_by != NULL && can_see )


hope you can help shed some light on this and sorry for being a whiny pain in the rear :D
Amended on Wed 28 Nov 2007 10:47 PM by Thrashmodule
USA #6
OK; the problem with the crypt lines is that it's not finding the function 'crypt', so it's assuming it's a function that returns an int; but, the code expects it to return a char*, hence the warnings where an int is being turned into a char*. If you do have libcrypt installed, you might be defining crypt into something else or something odd like that; I'd check your makefile flags and mud.h flags (do a text search for 'crypt' and see what comes up).

Quote:
if ( in_obj->carried_by != NULL && can_see )

The problem is that the code appears to expect can_see to be a boolean whereas it is in fact a function address. What I would do is look in the same function for local variables with similar names, like cansee: if you find one, chances are that the above is a typo. In this case, the warning is actually telling you something very helpful! :-)
USA #7
ok i'll give that a try I'll post what i find.

Found:


for ( obj = object_list; obj != NULL; obj = obj->next )
    {
        if ( !can_see_obj( ch, obj ) || !is_name( target_name, obj->name )
             || ( !IS_IMMORTAL( ch ) && number_percent(  ) > 2 * level )
             || ch->level < obj->level )
            continue;

        found = TRUE;
        number++;

        for ( in_obj = obj; in_obj->in_obj != NULL; in_obj = in_obj->in_obj )
            ;

        if ( in_obj->carried_by != NULL && can_see )
        {
            sprintf( buf, "%s carried by %s\n\r",
                     obj->short_descr, PERS( in_obj->carried_by, ch ) );
        }
        else
        {
            if ( IS_IMMORTAL( ch ) && in_obj->in_room != NULL )
                sprintf( buf, "%s in %s [Room %d]\n\r",
                         obj->short_descr,
                         in_obj->in_room->name, in_obj->in_room->vnum );
            else
                sprintf( buf, "%s in %s\n\r",
                         obj->short_descr, in_obj->in_room == NULL
                         ? "somewhere" : in_obj->in_room->name );
        }



is it maybe !can_see_obj or am i way off base?
Amended on Wed 28 Nov 2007 11:11 PM by Thrashmodule
USA #8
Quote:
The problem is that the code appears to expect can_see to be a boolean whereas it is in fact a function address. What I would do is look in the same function for local variables with similar names, like cansee: if you find one, chances are that the above is a typo. In this case, the warning is actually telling you something very helpful! :-)

You sure? Often times I've seen something like this:
bool can_see = can_see(ch, victim);

And that's what it could be referencing.
USA #9

void spell_locate_object( int sn, int level, CHAR_DATA * ch, void *vo )
{
    char buf[MAX_STRING_LENGTH];
    char buffer[4 * MAX_STRING_LENGTH];
    OBJ_DATA *obj;
    OBJ_DATA *in_obj;
    bool found;
    int number = 0, max_found;

    found = FALSE;
    number = 0;
    buffer[0] = '\0';
    max_found = IS_IMMORTAL( ch ) ? 200 : 2 * level;

    for ( obj = object_list; obj != NULL; obj = obj->next )
    {
        if ( !can_see_obj( ch, obj ) || !is_name( target_name, obj->name )
             || ( !IS_IMMORTAL( ch ) && number_percent(  ) > 2 * level )
             || ch->level < obj->level )
            continue;

        found = TRUE;
        number++;

        for ( in_obj = obj; in_obj->in_obj != NULL; in_obj = in_obj->in_obj )
            ;

        if ( in_obj->carried_by != NULL && can_see )
        {
            sprintf( buf, "%s carried by %s\n\r",
                     obj->short_descr, PERS( in_obj->carried_by, ch ) );
        }
        else
        {
            if ( IS_IMMORTAL( ch ) && in_obj->in_room != NULL )
                sprintf( buf, "%s in %s [Room %d]\n\r",
                         obj->short_descr,
                         in_obj->in_room->name, in_obj->in_room->vnum );
            else
                sprintf( buf, "%s in %s\n\r",
                         obj->short_descr, in_obj->in_room == NULL
                         ? "somewhere" : in_obj->in_room->name );
        }

        buf[0] = UPPER( buf[0] );
        strcat( buffer, buf );

        if ( number >= max_found )
            break;
    }

    if ( !found )
        send_to_char( "Nothing like that in heaven or earth.\n\r", ch );
    else if ( ch->lines )
        page_to_char( buffer, ch );
    else
        send_to_char( buffer, ch );

    return;
}




ok here is the entire function and as far as the file goes it has a couple instances of can_see_room and can_see_obj

but i cant figure out why they needed can_see?? or what the flag for can_see is supposed to be is there supposed to be another check in there for can_see??


EDIT: ok i removed && can_see and warning is gone going to have to beat this function up to see if it causes problems without that code. will post if i find anything still working on 1st set of warnings though :S
Amended on Thu 29 Nov 2007 08:34 AM by Thrashmodule
USA #10
As for crypt not being found, check out sha256 as provided by the SMAUGFuss project. It doesn't rely on system functions that may or may not be available, and hence is much more portable.
USA #11
Quote:
You sure? Often times I've seen something like this:

bool can_see = can_see(ch, victim);


And that's what it could be referencing.

If that is the case, then the can_see local variable does exist and shadows the global function declaration; that's terrible style but hey...

Quote:
but i cant figure out why they needed can_see?? or what the flag for can_see is supposed to be is there supposed to be another check in there for can_see??

They probably meant to say something like: can_see(ch, obj) or something like that. It's always hard to tell exactly what was meant by something in code like that... You'd think that whoever added that code would have seen the warning and done something about it, but far too many people have the attitude that a warning is just a warning and can be ignored. Oh well...
USA #12
thats what started this whole post lol i hate warnings they are annoying things that peck at the back of my brain screaming of future crashes and instabilities. i would prefer to not touch any code until i can get it to clean make crashes happen bugs get in but why leave the door wide open!

as for the sha256 I'm probably going to sound retarded but its been about 5 years since I've opened a src file and I have not a clue as to how to go about implementing that into my code base is there a sha256 for dummies book out there :D
from my brief reading it dosn't look to be a plug and play app whats the best way to go about the integration of that to fit my needs?

and again sorry for being an insurmountable pain in the posterior.
USA #13
Switching over to sha256 is simple thanks the crew of SMAUGFuss.
Go grab it from www.smaugmuds.org, locate sha256.c and sha256.h, add them to your Makefile, replace all crypt(blahA, blahB) calls with sha256_crypt(blahA). In comm.c and act_?.c add include the sha256 header.
The only downside to the change is that it doesn't worth preexisting characters. Perhaps if the passwords are reset, not sure. After that, it's just removing the old header files and other references to crypt, that can be done at your leisure.
Found here http://www.smaugmuds.org/index.php?a=files&s=viewfile&fid=2
Exact instructions and the files needed.
Amended on Thu 29 Nov 2007 01:52 PM by ThomasWatts
USA #14
Just be sure that if you're going to use the sha256 encryption you implement it before you've got a playerbase to worry about because the old crypt passwords won't be compatible.
USA #15
Does SMAUG have the ability to reset passwords? Or assign a temporary password? If e-mail information is recorded then a password could be generated then sent to the player e-mail. Then sha256 could be used with an existing player base although everyones passwords would have to be reset.
USA #16
Alas, while Smaug does have a command (or two) that an admin can use to change the password for someone else, email addresses are not saved anywhere, Smaug does not have any email interface already, and it doesn't auto-generate passwords. :(
USA #17
TYVM going to try and get this thing working right now i'll post later on how it went :D
USA #18
TY TY TY TY TY that did it CLEAN MAKE YAY now to start modding so i can screw it up :D have a great day/nite and tyvm again.