[Spice-devel] [PATCH spice-gtk 2/2] file-transfer: Add guards to public functions
Victor Toso
lists at victortoso.com
Thu Sep 1 10:43:55 UTC 2016
On Thu, Sep 01, 2016 at 11:33:14AM +0200, Pavel Grunt wrote:
> ---
> src/spice-file-transfer-task.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/src/spice-file-transfer-task.c b/src/spice-file-transfer-task.c
> index 96aef9f..e3fbcc7 100644
> --- a/src/spice-file-transfer-task.c
> +++ b/src/spice-file-transfer-task.c
> @@ -503,6 +503,8 @@ gboolean spice_file_transfer_task_is_completed(SpiceFileTransferTask *self)
> **/
> double spice_file_transfer_task_get_progress(SpiceFileTransferTask *self)
> {
> + g_return_val_if_fail(SPICE_IS_FILE_TRANSFER_TASK(self), 0.0);
> +
> if (self->file_size == 0)
> return 0.0;
>
> @@ -522,6 +524,8 @@ double spice_file_transfer_task_get_progress(SpiceFileTransferTask *self)
> **/
> void spice_file_transfer_task_cancel(SpiceFileTransferTask *self)
> {
> + g_return_if_fail(SPICE_IS_FILE_TRANSFER_TASK(self));
> +
> g_cancellable_cancel(self->cancellable);
> }
>
> @@ -537,6 +541,8 @@ void spice_file_transfer_task_cancel(SpiceFileTransferTask *self)
> **/
> char* spice_file_transfer_task_get_filename(SpiceFileTransferTask *self)
> {
> + g_return_val_if_fail(SPICE_IS_FILE_TRANSFER_TASK(self), NULL);
> +
Might as well to change the others to use the macro
SPICE_IS_FILE_TRANSFER_TASK as it does check for NULL already.
Acked-by: Victor Toso <victortoso at redhat.com>
(both patches) - feel free to ignore suggestion above if you don't think
is necessary
> return g_file_get_basename(self->file);
> }
>
> --
> 2.9.3
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list