mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
Fix printing of signed numbers
If any operand of the '?' operator is of an unsigned type, the result is unsigned by default. Thanks to Julian Stecklina for finding this out. Fixes #189.
This commit is contained in:
parent
2f2fd33d96
commit
4c4d4e5c63
32
base/run/printf.run
Normal file
32
base/run/printf.run
Normal file
@ -0,0 +1,32 @@
|
||||
build "core init test/printf"
|
||||
|
||||
create_boot_directory
|
||||
|
||||
install_config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="RM"/>
|
||||
<service name="CAP"/>
|
||||
<service name="PD"/>
|
||||
<service name="SIGNAL"/>
|
||||
<service name="LOG"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> </any-service>
|
||||
</default-route>
|
||||
<start name="test-printf">
|
||||
<resource name="RAM" quantum="10M"/>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
build_boot_image "core init test-printf"
|
||||
|
||||
append qemu_args "-nographic -m 64"
|
||||
|
||||
run_genode_until {-1 = -1 = -1} 10
|
||||
|
||||
puts "Test succeeded"
|
@ -276,7 +276,7 @@ void Console::vprintf(const char *format, va_list list)
|
||||
case Format_command::LONG:
|
||||
|
||||
numeric_arg = (cmd.type == Format_command::UINT) ?
|
||||
va_arg(list, unsigned long) : va_arg(list, long);
|
||||
(long long)va_arg(list, unsigned long) : va_arg(list, long);
|
||||
break;
|
||||
|
||||
case Format_command::SIZE_T:
|
||||
@ -287,7 +287,7 @@ void Console::vprintf(const char *format, va_list list)
|
||||
case Format_command::DEFAULT:
|
||||
|
||||
numeric_arg = (cmd.type == Format_command::UINT) ?
|
||||
va_arg(list, unsigned int) : va_arg(list, int);
|
||||
(long long)va_arg(list, unsigned int) : va_arg(list, int);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
22
base/src/test/printf/main.cc
Normal file
22
base/src/test/printf/main.cc
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* \brief Testing 'printf()' with negative integer
|
||||
* \author Christian Prochaska
|
||||
* \date 2012-04-20
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#include <base/printf.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Genode::printf("-1 = %d = %ld\n", -1, -1L);
|
||||
|
||||
return 0;
|
||||
}
|
3
base/src/test/printf/target.mk
Normal file
3
base/src/test/printf/target.mk
Normal file
@ -0,0 +1,3 @@
|
||||
TARGET = test-printf
|
||||
SRC_CC = main.cc
|
||||
LIBS = env
|
Loading…
Reference in New Issue
Block a user