Re: sprintf with mips

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sunday 10 February 2008 17:25:59 Christian Stalp wrote:
> The whole procedure is here: (its a thread!)
>
> void *dblogger_fn (void *arg)
> {
> 	char insertvalues[256];
> 	memset (insertvalues, 0x0, 256 );
>         conn = PQconnectdb("host=192.168.1.2 dbname=wlan_db  user=gavle
> password=brynaes"); tabellename = "traffic";
>
> 	if (PQstatus(conn) == CONNECTION_BAD)
> 	{
> 		fprintf(stderr, "Connection to database '%s' failed.\n",dbName);
> 		fprintf(stderr, "%s", PQerrorMessage(conn));
> 		exit_nicely(conn);
>   	}
>   	else if (PQstatus(conn) == CONNECTION_OK)
>   	{
>   		printf("Connected with database ...\n");
>   		printf("Datenbank : %s\n", PQdb(conn));
>   		printf("User      : %s\n", PQuser(conn));
>   	}
>   	while(1)
>   	{
>   		sleep(500);
>   		snprintf(insertvalues, 255 ," %d , ' %s ' , %d ", counter,
> "192.168.1.1", mytraffic->num_frames); printf("input-string: %s\n",
> insertvalues);
>   		printf("Counter: %d\n", counter);
> 		insertinto(dbName, conn, tabellename, insertvalues);
> 		counter++;
>   	}
>
> I don't know where is here a chance for an overflow? Consider, now with
> 'snprintf' it works, but before with sprintf there was this problem, BUT
> only on the mips-target board. On x86 it worked also with sprintf!
>
> Gruss Christian

I would recommend stepping through with a debugger. It might also be worth 
while to compile with the -S option (if using gcc) and peruse the MIPS 
assembly.

Stephen Kratzer
Network Engineer
CTI Networks, Inc.

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux