summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/utils
diff options
context:
space:
mode:
authorMatej Vasek <mvasek@redhat.com>2021-11-01 20:12:35 +0100
committerMatej Vasek <mvasek@redhat.com>2021-11-01 20:12:35 +0100
commita845613d03db2c15c2aade29f78cd74c28957f1b (patch)
tree36b1b51e821e5f7aa78a47ba313135a2b4f4bc29 /pkg/api/handlers/utils
parent120ad2d3ca0ac04a3421d620a8fdf06c472abd2c (diff)
downloadpodman-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/api/handlers/utils')
-rw-r--r--pkg/api/handlers/utils/handler.go8
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