All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] cpu: Clean up includes
@ 2016-01-18 17:35 Peter Maydell
  2016-01-18 18:00 ` Andreas Färber
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2016-01-18 17:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Andreas Färber, patches

Clean up includes so that osdep.h is included first and headers
which it implies are not included manually.

This commit was created with scripts/clean-includes.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 qom/cpu.c         | 1 +
 target-i386/cpu.c | 5 +----
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/qom/cpu.c b/qom/cpu.c
index 8f537a4..edd6b6a 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -18,6 +18,7 @@
  * <http://www.gnu.org/licenses/gpl-2.0.html>
  */
 
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qom/cpu.h"
 #include "sysemu/kvm.h"
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 0d447b5..1e3b98a 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -16,10 +16,7 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <inttypes.h>
+#include "qemu/osdep.h"
 
 #include "cpu.h"
 #include "sysemu/kvm.h"
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] cpu: Clean up includes
  2016-01-18 17:35 [Qemu-devel] [PATCH] cpu: Clean up includes Peter Maydell
@ 2016-01-18 18:00 ` Andreas Färber
  2016-01-18 18:05   ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Färber @ 2016-01-18 18:00 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches

Am 18.01.2016 um 18:35 schrieb Peter Maydell:
> Clean up includes so that osdep.h is included first and headers
> which it implies are not included manually.
> 
> This commit was created with scripts/clean-includes.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  qom/cpu.c         | 1 +
>  target-i386/cpu.c | 5 +----
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/qom/cpu.c b/qom/cpu.c
> index 8f537a4..edd6b6a 100644
> --- a/qom/cpu.c
> +++ b/qom/cpu.c
> @@ -18,6 +18,7 @@
>   * <http://www.gnu.org/licenses/gpl-2.0.html>
>   */
>  
> +#include "qemu/osdep.h"
>  #include "qemu-common.h"

Shouldn't qemu-common.h include osdep.h?

Otherwise looks okay.

Regards,
Andreas

>  #include "qom/cpu.h"
>  #include "sysemu/kvm.h"
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 0d447b5..1e3b98a 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -16,10 +16,7 @@
>   * You should have received a copy of the GNU Lesser General Public
>   * License along with this library; if not, see <http://www.gnu.org/licenses/>.
>   */
> -#include <stdlib.h>
> -#include <stdio.h>
> -#include <string.h>
> -#include <inttypes.h>
> +#include "qemu/osdep.h"
>  
>  #include "cpu.h"
>  #include "sysemu/kvm.h"

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] cpu: Clean up includes
  2016-01-18 18:00 ` Andreas Färber
@ 2016-01-18 18:05   ` Peter Maydell
  2016-01-18 21:27     ` Eric Blake
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2016-01-18 18:05 UTC (permalink / raw)
  To: Andreas Färber; +Cc: QEMU Developers, Patch Tracking

On 18 January 2016 at 18:00, Andreas Färber <afaerber@suse.de> wrote:
> Am 18.01.2016 um 18:35 schrieb Peter Maydell:
>> Clean up includes so that osdep.h is included first and headers
>> which it implies are not included manually.
>>
>> This commit was created with scripts/clean-includes.
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>>  qom/cpu.c         | 1 +
>>  target-i386/cpu.c | 5 +----
>>  2 files changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/qom/cpu.c b/qom/cpu.c
>> index 8f537a4..edd6b6a 100644
>> --- a/qom/cpu.c
>> +++ b/qom/cpu.c
>> @@ -18,6 +18,7 @@
>>   * <http://www.gnu.org/licenses/gpl-2.0.html>
>>   */
>>
>> +#include "qemu/osdep.h"
>>  #include "qemu-common.h"
>
> Shouldn't qemu-common.h include osdep.h?

It does, but the intention is that every .c file should include
qemu/osdep.h as its first include (even if some other include
it has also results in osdep.h being pulled in). This is a simple
rule that's easy to check in code review and hopefully also
in an automated way. It should also help us in future
disentangling of some of the things that qemu-common.h pulls in
into their own header files.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] cpu: Clean up includes
  2016-01-18 18:05   ` Peter Maydell
@ 2016-01-18 21:27     ` Eric Blake
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Blake @ 2016-01-18 21:27 UTC (permalink / raw)
  To: Peter Maydell, Andreas Färber; +Cc: QEMU Developers, Patch Tracking

[-- Attachment #1: Type: text/plain, Size: 1367 bytes --]

On 01/18/2016 11:05 AM, Peter Maydell wrote:

>>> +++ b/qom/cpu.c
>>> @@ -18,6 +18,7 @@
>>>   * <http://www.gnu.org/licenses/gpl-2.0.html>
>>>   */
>>>
>>> +#include "qemu/osdep.h"
>>>  #include "qemu-common.h"
>>
>> Shouldn't qemu-common.h include osdep.h?
> 
> It does, but the intention is that every .c file should include
> qemu/osdep.h as its first include (even if some other include
> it has also results in osdep.h being pulled in).

Eventually, we want to force that NO .h file includes qemu/osdep.h.  If
every .c file includes it first, then all other .h files can count on it
already being included and therefore don't need to include it
themselves.  (This is comparable to the rule used in other projects,
like libvirt's handling of config.h which must be first in all .c files
and must not be included in .h files).

> This is a simple
> rule that's easy to check in code review and hopefully also
> in an automated way.

Indeed - we MUST turn on automation after all these individual patches
are in, to make sure we don't regress (again, something that libvirt has
already managed to do, so it shouldn't be too hard to automate, except
that libvirt's automation is courtesy of gnulib which we don't use here).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-18 21:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-18 17:35 [Qemu-devel] [PATCH] cpu: Clean up includes Peter Maydell
2016-01-18 18:00 ` Andreas Färber
2016-01-18 18:05   ` Peter Maydell
2016-01-18 21:27     ` Eric Blake

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.