* [Qemu-devel] Why QEMUClock is defined in qemu-timer.c?
@ 2012-01-31 5:55 Richard Yang
2012-01-31 6:12 ` Mulyadi Santosa
0 siblings, 1 reply; 5+ messages in thread
From: Richard Yang @ 2012-01-31 5:55 UTC (permalink / raw)
To: qemu-devel
Hi, experts
I am just coming to the qemu world.
While reading the code, I am wondering why put a struct definition in the
c file?
Seems there is no error in compile, while I felt it is not a proper way
to do it.
--
Richard Yang
Help you, Help me
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] Why QEMUClock is defined in qemu-timer.c?
2012-01-31 5:55 [Qemu-devel] Why QEMUClock is defined in qemu-timer.c? Richard Yang
@ 2012-01-31 6:12 ` Mulyadi Santosa
2012-01-31 6:35 ` Richard Yang
0 siblings, 1 reply; 5+ messages in thread
From: Mulyadi Santosa @ 2012-01-31 6:12 UTC (permalink / raw)
To: Richard Yang; +Cc: qemu-devel
Hi :)
On Tue, Jan 31, 2012 at 12:55, Richard Yang <weiyang@linux.vnet.ibm.com> wrote:
>
> Hi, experts
>
> I am just coming to the qemu world.
>
> While reading the code, I am wondering why put a struct definition in the
> c file?
>
> Seems there is no error in compile, while I felt it is not a proper way
> to do it.
maybe someone just forgot to refactor it :) I suggest to send a patch
to do just that and let's see what everybody thinks about. I, myself
thinks that the more readable the code is, the better
--
regards,
Mulyadi Santosa
Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] Why QEMUClock is defined in qemu-timer.c?
2012-01-31 6:12 ` Mulyadi Santosa
@ 2012-01-31 6:35 ` Richard Yang
2012-01-31 10:00 ` Dmitry Zamaruev
0 siblings, 1 reply; 5+ messages in thread
From: Richard Yang @ 2012-01-31 6:35 UTC (permalink / raw)
To: Mulyadi Santosa; +Cc: Richard Yang, qemu-devel
On Tue, Jan 31, 2012 at 01:12:24PM +0700, Mulyadi Santosa wrote:
>Hi :)
>
>On Tue, Jan 31, 2012 at 12:55, Richard Yang <weiyang@linux.vnet.ibm.com> wrote:
>>
>> Hi, experts
>>
>> I am just coming to the qemu world.
>>
>> While reading the code, I am wondering why put a struct definition in the
>> c file?
>>
>> Seems there is no error in compile, while I felt it is not a proper way
>> to do it.
>
>
>maybe someone just forgot to refactor it :) I suggest to send a patch
>to do just that and let's see what everybody thinks about. I, myself
>thinks that the more readable the code is, the better
Ok, let me do it.
>
>--
>regards,
>
>Mulyadi Santosa
>Freelance Linux trainer and consultant
>
>blog: the-hydra.blogspot.com
>training: mulyaditraining.blogspot.com
--
Richard Yang
Help you, Help me
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] Why QEMUClock is defined in qemu-timer.c?
2012-01-31 6:35 ` Richard Yang
@ 2012-01-31 10:00 ` Dmitry Zamaruev
2012-02-01 1:33 ` Richard Yang
0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Zamaruev @ 2012-01-31 10:00 UTC (permalink / raw)
To: Richard Yang; +Cc: qemu-devel
This is used in many places.
Maybe to simulate 'private' variables and access methods like in C++.
If you define structure in .c file then every function that works with
this structure must reside in same file. And any other code to use
structure must use access-functions (api) to alter it and not directly
(compiler will issue error about incomplete type).
This way you could change structure or internal data handling without
affecting external code that relies on "stable api functions".
On Tue, Jan 31, 2012 at 8:35 AM, Richard Yang
<weiyang@linux.vnet.ibm.com> wrote:
> On Tue, Jan 31, 2012 at 01:12:24PM +0700, Mulyadi Santosa wrote:
>>Hi :)
>>
>>On Tue, Jan 31, 2012 at 12:55, Richard Yang <weiyang@linux.vnet.ibm.com> wrote:
>>>
>>> Hi, experts
>>>
>>> I am just coming to the qemu world.
>>>
>>> While reading the code, I am wondering why put a struct definition in the
>>> c file?
>>>
>>> Seems there is no error in compile, while I felt it is not a proper way
>>> to do it.
>>
>>
>>maybe someone just forgot to refactor it :) I suggest to send a patch
>>to do just that and let's see what everybody thinks about. I, myself
>>thinks that the more readable the code is, the better
>
> Ok, let me do it.
>>
>>--
>>regards,
>>
>>Mulyadi Santosa
>>Freelance Linux trainer and consultant
>>
>>blog: the-hydra.blogspot.com
>>training: mulyaditraining.blogspot.com
>
> --
> Richard Yang
> Help you, Help me
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] Why QEMUClock is defined in qemu-timer.c?
2012-01-31 10:00 ` Dmitry Zamaruev
@ 2012-02-01 1:33 ` Richard Yang
0 siblings, 0 replies; 5+ messages in thread
From: Richard Yang @ 2012-02-01 1:33 UTC (permalink / raw)
To: Dmitry Zamaruev; +Cc: Richard Yang, qemu-devel
On Tue, Jan 31, 2012 at 12:00:30PM +0200, Dmitry Zamaruev wrote:
>This is used in many places.
>Maybe to simulate 'private' variables and access methods like in C++.
>
>If you define structure in .c file then every function that works with
>this structure must reside in same file. And any other code to use
>structure must use access-functions (api) to alter it and not directly
>(compiler will issue error about incomplete type).
>This way you could change structure or internal data handling without
>affecting external code that relies on "stable api functions".
Thanks for your explanation.
I learned a lot.
--
Richard Yang
Help you, Help me
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-02-01 1:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-31 5:55 [Qemu-devel] Why QEMUClock is defined in qemu-timer.c? Richard Yang
2012-01-31 6:12 ` Mulyadi Santosa
2012-01-31 6:35 ` Richard Yang
2012-01-31 10:00 ` Dmitry Zamaruev
2012-02-01 1:33 ` Richard Yang
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 NNTP newsgroup(s).