|
From: Kevin N. <kev...@or...> - 2008-08-20 00:00:27
|
A few thoughts:
1. maybe when you call this function, you are passing uninitialized
values for the int parameters?
2. this apparently is not the whole function, since there is no end
brace, and since you don't do anything with lotN or the last value of
container
3. this could sure be a lot easier using C's sprintf, and almost
certainly using C++ strings
using sprintf:
char ser[10*3+1];
sprintf(ser, "%d%03d%05d", denomNumber, cluster, lot);
aruperez wrote:
>
> Christoph Bartoschek-2 wrote:
>
>> Your example code looks ok. Show us the real code.
>>
>> Christoph
>>
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>> challenge
>> Build the coolest Linux based applications with Moblin SDK & win great
>> prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the
>> world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Valgrind-users mailing list
>> Val...@li...
>> https://lists.sourceforge.net/lists/listinfo/valgrind-users
>>
>>
>>
>
> Well is very much the same but here it is
>
> string packSerial(int denomNumber, int cluster, int lot, int sublot, int
> serial){
>
> char ser[11];
>
> string container;
>
> string lotN = string();
>
>
>
> sprintf(ser,"%d",denomNumber);
>
> container = string(ser);
>
> lotN.append(container.c_str());
>
> sprintf(ser,"%d",cluster);
>
> container = string(ser);
>
> while(container.length()<3){
>
> container = string('0'+container);
>
> }
>
> lotN.append(container.c_str());
>
> sprintf(ser,"%d",lot);
>
> container = string(ser);
>
> while(container.length()<5){
>
> container = string('0'+container);
>
> }
>
> for every one of the sprintf calls valgrind says
>
> Conditional jump or move depends on uninitialised value(s)
> ==28593== at 0x43820E5: vfprintf (in /lib/libc-2.6.1.so)
> ==28593== by 0x439E91B: vsprintf (in /lib/libc-2.6.1.so)
> ==28593== by 0x438A42D: sprintf (in /lib/libc-2.6.1.so)
> ==28593== by 0x806D42E: card_manager::packSerial(int, int, int, int, int)
> (card_manager.cpp:431)
> ==28593== by 0x807396B: card_manager::gen_keys(int, int, int, int,
> std::string) (card_manager.cpp:280)
> ==28593== by 0x8076BE2: command_interpreter::interpret(iso8583_frame
> const&) (command_interpreter.cpp:126)
> ==28593== by 0x8078642: request_handler::con_handling(request)
> (request_handler.cpp:55)
> ==28593== by 0x80787AE: request_handler::handle(request)
> (request_handler.cpp:25)
> ==28593== by 0x807888F: queue_process::consume(void*)
> (queue_process.cpp:69)
> ==28593== by 0x805CBAF: Consume(void*) (queue_process.cpp:78)
> ==28593== by 0x41CA191: start_thread (in /lib/libpthread-2.6.1.so)
> ==28593== by 0x440802D: clone (in /lib/libc-2.6.1.so)
>
>
> thanks for any help
>
>
>
>
|