[PATCH 8/8] src: drop some forward declarations in src/storage/storage_backend_sheepdog.c

Michal Privoznik mprivozn at redhat.com
Mon Mar 29 08:36:37 UTC 2021


On 3/27/21 3:54 AM, peili wrote:
> ---
>   src/storage/storage_backend_sheepdog.c | 6 ------
>   1 file changed, 6 deletions(-)
> 
> diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
> index 8c37947308..010e86aa14 100644
> --- a/src/storage/storage_backend_sheepdog.c
> +++ b/src/storage/storage_backend_sheepdog.c
> @@ -35,12 +35,6 @@
>   
>   #define VIR_FROM_THIS VIR_FROM_STORAGE
>   
> -static int virStorageBackendSheepdogRefreshVol(virStoragePoolObjPtr pool,
> -                                               virStorageVolDefPtr vol);
> -
> -void virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
> -                                         virStoragePoolObjPtr pool);
> -
>   int
>   virStorageBackendSheepdogParseNodeInfo(virStoragePoolDefPtr pool,
>                                          char *output)
> 

Unfortunately, dropping forward declarations is not that easy. For 
instance in the following example:

int foo() {
   ...
   bar();
   ...
}


int bar() {
   ...
   foo();
   ...
}


This block has to be prefaced with forward declaration of bar() because 
as compiler parses the input, it sees foo() (among with it declaration), 
and then it sees bar() being called, but since it did not see its 
declaration yet, it can't ensure that arguments passed are correct type, 
correct count, ...;  therefore, bar() has to be declared before before 
foo().

However, consider the following case:

int foo() {
   ...
   // no bar() call here
   ...
}


int bar() {
   ...
   foo();
   ...
}

here, function foo() does NOT call bar() and therefore, there is no need 
for forward declaration of bar().

Michal




More information about the libvir-list mailing list