Move to kernel style SPDX license identifiers
[lttng-ust.git] / libcounter / counter-api.h
index 0a7c0adeecc5f3fb46cdea8d191934eb4113e903..cfce44d9dd9c2b61bc0012e102b3189b3f95e15f 100644 (file)
@@ -1,27 +1,9 @@
 /*
- * counter/counter-api.h
- *
- * LTTng Counters API, requiring counter/config.h
+ * SPDX-License-Identifier: MIT
  *
  * Copyright (C) 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * LTTng Counters API, requiring counter/config.h
  */
 
 #ifndef _LTTNG_COUNTER_API_H
@@ -101,10 +83,12 @@ static inline int __lttng_counter_add(const struct lib_counter_config *config,
                        } while (old != res);
                        break;
                }
+               default:
+                       return -EINVAL;
                }
                if (v > 0 && (v >= UINT8_MAX || n < old))
                        overflow = true;
-               else if (v < 0 && (v <= -UINT8_MAX || n > old))
+               else if (v < 0 && (v <= -(int64_t) UINT8_MAX || n > old))
                        underflow = true;
                break;
        }
@@ -140,10 +124,12 @@ static inline int __lttng_counter_add(const struct lib_counter_config *config,
                        } while (old != res);
                        break;
                }
+               default:
+                       return -EINVAL;
                }
                if (v > 0 && (v >= UINT16_MAX || n < old))
                        overflow = true;
-               else if (v < 0 && (v <= -UINT16_MAX || n > old))
+               else if (v < 0 && (v <= -(int64_t) UINT16_MAX || n > old))
                        underflow = true;
                break;
        }
@@ -179,10 +165,12 @@ static inline int __lttng_counter_add(const struct lib_counter_config *config,
                        } while (old != res);
                        break;
                }
+               default:
+                       return -EINVAL;
                }
                if (v > 0 && (v >= UINT32_MAX || n < old))
                        overflow = true;
-               else if (v < 0 && (v <= -UINT32_MAX || n > old))
+               else if (v < 0 && (v <= -(int64_t) UINT32_MAX || n > old))
                        underflow = true;
                break;
        }
@@ -219,6 +207,8 @@ static inline int __lttng_counter_add(const struct lib_counter_config *config,
                        } while (old != res);
                        break;
                }
+               default:
+                       return -EINVAL;
                }
                if (v > 0 && n < old)
                        overflow = true;
This page took 0.024875 seconds and 4 git commands to generate.