* thread name made constant...
@ 2008-12-24 0:09 Andrew Lunn
2008-12-24 16:36 ` Bart Veer
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2008-12-24 0:09 UTC (permalink / raw)
To: eCos Patches
[-- Attachment #1: Type: text/plain, Size: 993 bytes --]
I wanted to fix a compiler warning in mainthread.cxx which snowballed
into something a bit bigger.
Newer versions of gcc C++ compile complains about passing a constant
string to a function which expects a char *. The mainthread.cxx does
this:
Cyg_Thread cyg_libc_main_thread CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_LIBC) =
Cyg_Thread(CYGNUM_LIBC_MAIN_THREAD_PRIORITY,
&cyg_libc_invoke_main, (CYG_ADDRWORD) 0,
"main",
(CYG_ADDRESS) &cyg_libc_main_stack[0],
#ifdef CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM
CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE
#else
cyg_libc_main_stack_size
#endif
);
"main" is a constant string, but Cyg_Thread() wants a char *. The
kernel never changes the thread name, so rather than adding a char *
cast i modified the KAPI to expect a const char *. This effectively
changes the kernel API, so before i commit it i though it best to get
comments.
Andrew
[-- Attachment #2: kernel_const.diff --]
[-- Type: text/x-diff, Size: 10010 bytes --]
Index: kernel/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/ChangeLog,v
retrieving revision 1.149
diff -u -r1.149 ChangeLog
--- kernel/current/ChangeLog 18 Dec 2008 18:31:44 -0000 1.149
+++ kernel/current/ChangeLog 24 Dec 2008 00:00:39 -0000
@@ -1,3 +1,15 @@
+2008-12-23 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * doc/kernel.sgml, include/kapi.h, include/thread.hxx,
+ include/thread.inl, src/common/kapi.cxx, src/common/thread.cxx:
+ Make the thread name a constant, which fixes some compiler
+ warnings.
+ * tests/mutex3.cxx (control_thread): const correctness to remove a
+ compiler warning.
+ * tests/intr0.cxx (intr0_main): Remove CHECK() which can never
+ fail and produces a compiler warning.
+ * tests/tm_basic.cxx: Const correctness to remove compiler warnings.
+
2008-12-18 Jonathan Larmour <jifl@eCosCentric.com>
* tests/tm_basic.cxx (STACK_SIZE): Revert accidental change of
Index: kernel/current/doc/kernel.sgml
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/doc/kernel.sgml,v
retrieving revision 1.14
diff -u -r1.14 kernel.sgml
--- kernel/current/doc/kernel.sgml 21 Aug 2006 17:13:45 -0000 1.14
+++ kernel/current/doc/kernel.sgml 24 Dec 2008 00:00:44 -0000
@@ -982,7 +982,7 @@
<paramdef>cyg_addrword_t <parameter>sched_info</parameter></paramdef>
<paramdef>cyg_thread_entry_t* <parameter>entry</parameter></paramdef>
<paramdef>cyg_addrword_t <parameter>entry_data</parameter></paramdef>
- <paramdef>char* <parameter>name</parameter></paramdef>
+ <paramdef>const char* <parameter>name</parameter></paramdef>
<paramdef>void* <parameter>stack_base</parameter></paramdef>
<paramdef>cyg_ucount32 <parameter>stack_size</parameter></paramdef>
<paramdef>cyg_handle_t* <parameter>handle</parameter></paramdef>
@@ -1398,7 +1398,7 @@
<type>cyg_handle_t</type> <structfield>handle</structfield>;
<type>cyg_uint16</type> <structfield>id</structfield>;
<type>cyg_uint32</type> <structfield>state</structfield>;
- <type>char</type> <structfield>*name</structfield>;
+ <type>const char</type> <structfield>*name</structfield>;
<type>cyg_priority_t</type> <structfield>set_pri</structfield>;
<type>cyg_priority_t</type> <structfield>cur_pri</structfield>;
<type>cyg_addrword_t</type> <structfield>stack_base</structfield>;
Index: kernel/current/include/kapi.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/include/kapi.h,v
retrieving revision 1.20
diff -u -r1.20 kapi.h
--- kernel/current/include/kapi.h 15 Mar 2004 15:20:53 -0000 1.20
+++ kernel/current/include/kapi.h 24 Dec 2008 00:00:44 -0000
@@ -155,7 +155,7 @@
cyg_addrword_t sched_info, /* scheduling info (eg pri) */
cyg_thread_entry_t *entry, /* entry point function */
cyg_addrword_t entry_data, /* entry data */
- char *name, /* optional thread name */
+ const char *name, /* optional thread name */
void *stack_base, /* stack base, NULL = alloc */
cyg_ucount32 stack_size, /* stack size, 0 = default */
cyg_handle_t *handle, /* returned thread handle */
@@ -215,7 +215,7 @@
cyg_handle_t handle;
cyg_uint16 id;
cyg_uint32 state;
- char *name;
+ const char *name;
cyg_priority_t set_pri;
cyg_priority_t cur_pri;
cyg_addrword_t stack_base;
Index: kernel/current/include/thread.hxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/include/thread.hxx,v
retrieving revision 1.12
diff -u -r1.12 thread.hxx
--- kernel/current/include/thread.hxx 28 Mar 2006 10:06:53 -0000 1.12
+++ kernel/current/include/thread.hxx 24 Dec 2008 00:00:45 -0000
@@ -306,7 +306,7 @@
CYG_ADDRWORD sched_info, // Scheduling parameter(s)
cyg_thread_entry *entry, // entry point function
CYG_ADDRWORD entry_data, // entry data
- char *name, // thread name
+ const char *name, // thread name
CYG_ADDRESS stack_base = 0, // stack base, NULL = allocate
cyg_ucount32 stack_size = 0 // stack size, 0 = use default
);
Index: kernel/current/include/thread.inl
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/include/thread.inl,v
retrieving revision 1.17
diff -u -r1.17 thread.inl
--- kernel/current/include/thread.inl 11 Nov 2008 04:31:57 -0000 1.17
+++ kernel/current/include/thread.inl 24 Dec 2008 00:00:45 -0000
@@ -521,7 +521,7 @@
#ifdef CYGVAR_KERNEL_THREADS_NAME
-inline char *Cyg_Thread::get_name()
+inline const char *Cyg_Thread::get_name()
{
return name;
}
Index: kernel/current/src/common/kapi.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/src/common/kapi.cxx,v
retrieving revision 1.24
diff -u -r1.24 kapi.cxx
--- kernel/current/src/common/kapi.cxx 15 Mar 2004 15:20:53 -0000 1.24
+++ kernel/current/src/common/kapi.cxx 24 Dec 2008 00:00:46 -0000
@@ -159,7 +159,7 @@
cyg_addrword_t sched_info, /* scheduling info (eg pri) */
cyg_thread_entry_t *entry, /* entry point function */
cyg_addrword_t entry_data, /* entry data */
- char *name, /* optional thread name */
+ const char *name, /* optional thread name */
void *stack_base, /* stack base, NULL = alloc */
cyg_ucount32 stack_size, /* stack size, 0 = default */
cyg_handle_t *handle, /* returned thread handle */
Index: kernel/current/src/common/thread.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/src/common/thread.cxx,v
retrieving revision 1.23
diff -u -r1.23 thread.cxx
--- kernel/current/src/common/thread.cxx 2 Jul 2007 11:49:10 -0000 1.23
+++ kernel/current/src/common/thread.cxx 24 Dec 2008 00:00:46 -0000
@@ -173,7 +173,7 @@
CYG_ADDRWORD sched_info, // Scheduling parameter(s)
cyg_thread_entry *entry, // entry point function
CYG_ADDRWORD entry_data, // entry data
- char *name_arg, // thread name cookie
+ const char *name_arg, // thread name cookie
CYG_ADDRESS stack_base, // stack base, NULL = allocate
cyg_ucount32 stack_size // stack size, 0 = use default
)
@@ -251,9 +251,9 @@
cyg_priority pri = get_priority();
#ifdef CYGVAR_KERNEL_THREADS_NAME
- char * name_arg = name;
+ const char * name_arg = name;
#else
- char * name_arg = NULL;
+ const char * name_arg = NULL;
#endif
new(this) Cyg_Thread( pri,
Index: kernel/current/tests/intr0.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/tests/intr0.cxx,v
retrieving revision 1.14
diff -u -r1.14 intr0.cxx
--- kernel/current/tests/intr0.cxx 15 Sep 2007 14:42:40 -0000 1.14
+++ kernel/current/tests/intr0.cxx 24 Dec 2008 00:00:46 -0000
@@ -199,8 +199,6 @@
Cyg_Interrupt::get_vsr( v, &new_vsr );
CHECK( old_vsr == new_vsr );
- CHECK( NULL != vsr0 );
-
cyg_vector v1;
#ifdef CYGPKG_HAL_MIPS_TX39
// This can be removed when PR 17831 is fixed
Index: kernel/current/tests/mutex3.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/tests/mutex3.cxx,v
retrieving revision 1.13
diff -u -r1.13 mutex3.cxx
--- kernel/current/tests/mutex3.cxx 3 Aug 2005 20:57:41 -0000 1.13
+++ kernel/current/tests/mutex3.cxx 24 Dec 2008 00:00:47 -0000
@@ -434,7 +434,7 @@
new_thread( extra_thread, 3, 17, l ); // Slot 6
{
- static char *a[] = { "inactive", "run early", "run late" };
+ static const char *a[] = { "inactive", "run early", "run late" };
diag_printf( "\n----- [%2d] New Cycle: 0x%02x, Threads 1a %s, 2a %s, 3a %s -----\n",
i, d, a[j], a[k], a[l] );
}
Index: kernel/current/tests/tm_basic.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/tests/tm_basic.cxx,v
retrieving revision 1.27
diff -u -r1.27 tm_basic.cxx
--- kernel/current/tests/tm_basic.cxx 18 Dec 2008 18:31:44 -0000 1.27
+++ kernel/current/tests/tm_basic.cxx 24 Dec 2008 00:00:48 -0000
@@ -301,7 +301,7 @@
}
void
-show_times_detail(fun_times ft[], int nsamples, char *title, bool ignore_first)
+show_times_detail(fun_times ft[], int nsamples, const char *title, bool ignore_first)
{
int i, delta, min, max, con_ave, con_min, ave_dev;
int start_sample, total_samples;
@@ -377,7 +377,7 @@
}
void
-show_times(fun_times ft[], int nsamples, char *title)
+show_times(fun_times ft[], int nsamples, const char *title)
{
show_times_detail(ft, nsamples, title, false);
#ifdef STATS_WITHOUT_FIRST_SAMPLE
@@ -413,8 +413,8 @@
}
// Compute a name for a thread
-char *
-thread_name(char *basename, int indx) {
+const char *
+thread_name(const char *basename, int indx) {
return "<<NULL>>"; // Not currently used
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: thread name made constant...
2008-12-24 0:09 thread name made constant Andrew Lunn
@ 2008-12-24 16:36 ` Bart Veer
2008-12-24 20:31 ` Andrew Lunn
0 siblings, 1 reply; 4+ messages in thread
From: Bart Veer @ 2008-12-24 16:36 UTC (permalink / raw)
To: Andrew Lunn; +Cc: ecos-patches
>>>>> "Andrew" == Andrew Lunn <andrew@lunn.ch> writes:
Andrew> I wanted to fix a compiler warning in mainthread.cxx which
Andrew> snowballed into something a bit bigger.
Andrew> Newer versions of gcc C++ compile complains about passing
Andrew> a constant string to a function which expects a char *.
Andrew> The mainthread.cxx does this:
Andrew> Cyg_Thread cyg_libc_main_thread CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_LIBC) =
Andrew> Cyg_Thread(CYGNUM_LIBC_MAIN_THREAD_PRIORITY,
Andrew> &cyg_libc_invoke_main, (CYG_ADDRWORD) 0,
Andrew> "main",
Andrew> (CYG_ADDRESS) &cyg_libc_main_stack[0],
Andrew> #ifdef CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM
Andrew> CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE
Andrew> #else
Andrew> cyg_libc_main_stack_size
Andrew> #endif
Andrew> );
Andrew> "main" is a constant string, but Cyg_Thread() wants a char
Andrew> *. The kernel never changes the thread name, so rather
Andrew> than adding a char * cast i modified the KAPI to expect a
Andrew> const char *. This effectively changes the kernel API, so
Andrew> before i commit it i though it best to get comments.
The current plan is to make those warnings go away by adding
-Wno-write-strings to the compiler flags. I have no objections to
fixing e.g. const correctness in the kernel. However we also have an
awful lot of imported code, e.g. the TCP/IP stacks. Those may have
APIs which are not const-correct, and we really don't want to go
around fixing all of those and making future merges more difficult. I
think this may be a case where the compiler warnings are more trouble
than they are worth.
Bart
--
Bart Veer eCos Configuration Architect
eCosCentric Limited The eCos experts http://www.ecoscentric.com/
Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: thread name made constant...
2008-12-24 16:36 ` Bart Veer
@ 2008-12-24 20:31 ` Andrew Lunn
2008-12-25 0:03 ` Rutger Hofman
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2008-12-24 20:31 UTC (permalink / raw)
To: Bart Veer; +Cc: eCos Patches
> The current plan is to make those warnings go away by adding
> -Wno-write-strings to the compiler flags.
O.K. Any other compiler flag tweaks planned? The inlining failed
warning is generating the most noise during the build.
> I have no objections to fixing e.g. const correctness in the kernel.
O.K, i'l leave it another day for others to comment before committing.
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: thread name made constant...
2008-12-24 20:31 ` Andrew Lunn
@ 2008-12-25 0:03 ` Rutger Hofman
0 siblings, 0 replies; 4+ messages in thread
From: Rutger Hofman @ 2008-12-25 0:03 UTC (permalink / raw)
Cc: eCos Patches
Andrew Lunn wrote:
>> The current plan is to make those warnings go away by adding
>> -Wno-write-strings to the compiler flags.
>
> O.K. Any other compiler flag tweaks planned? The inlining failed
> warning is generating the most noise during the build.
Besides the obvious -Wall -Wundef I like:
-Werror -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes
and, indeed, nowadays to do away with the inlining failed warning:
-Wno-inline
As far as I am concerned, individual (imported) packages can filter out
-Werror in their package .cdl.
Rutger Hofman
VU Amserdam
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-12-25 0:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-24 0:09 thread name made constant Andrew Lunn
2008-12-24 16:36 ` Bart Veer
2008-12-24 20:31 ` Andrew Lunn
2008-12-25 0:03 ` Rutger Hofman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).