diff options
author | Matej Vasek <mvasek@redhat.com> | 2021-11-01 20:12:35 +0100 |
---|---|---|
committer | Matej Vasek <mvasek@redhat.com> | 2021-11-01 20:12:35 +0100 |
commit | a845613d03db2c15c2aade29f78cd74c28957f1b (patch) | |
tree | 36b1b51e821e5f7aa78a47ba313135a2b4f4bc29 /pkg | |
parent | 120ad2d3ca0ac04a3421d620a8fdf06c472abd2c (diff) | |
download | podman-a845613d03db2c15c2aade29f78cd74c28957f1b.tar.gz podman-a845613d03db2c15c2aade29f78cd74c28957f1b.tar.bz2 podman-a845613d03db2c15c2aade29f78cd74c28957f1b.zip |
Better emptiness test for custom JSON serializer
Signed-off-by: Matej Vasek <mvasek@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/api/handlers/utils/handler.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/pkg/api/handlers/utils/handler.go b/pkg/api/handlers/utils/handler.go index 29139a98e..96b7a957c 100644 --- a/pkg/api/handlers/utils/handler.go +++ b/pkg/api/handlers/utils/handler.go @@ -145,12 +145,12 @@ func MarshalErrorSliceJSON(ptr unsafe.Pointer, stream *jsoniter.Stream) { } } -func MarshalErrorJSONIsEmpty(_ unsafe.Pointer) bool { - return false +func MarshalErrorJSONIsEmpty(ptr unsafe.Pointer) bool { + return *((*error)(ptr)) == nil } -func MarshalErrorSliceJSONIsEmpty(_ unsafe.Pointer) bool { - return false +func MarshalErrorSliceJSONIsEmpty(ptr unsafe.Pointer) bool { + return len(*((*[]error)(ptr))) <= 0 } // WriteJSON writes an interface value encoded as JSON to w |