LCOV - code coverage report
Current view: top level - src - error.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 14 16 87.5 %
Date: 2020-09-22 18:03:19 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // System Includes
       2             : #include <stdarg.h> // va_list, va_start, va_end
       3             : #include <stdio.h>  // snprintf, vsnprintf
       4             : #include <string.h> // strncmp
       5             : 
       6             : // Internal Includes
       7             : #include "kirke/error.h"
       8             : #include "kirke/log.h"
       9             : 
      10           2 : void error__set( Error *error, const char* type, unsigned long long code, const char* format, ... ){
      11           2 :     RETURN_IF_FAIL( error != NULL );
      12             : 
      13           2 :     if( error->code != Error__None ){
      14           0 :         log__warning( "error__set:  Overwriting existing destination error.  Destination should be cleared with error__reset before calling error__set." );
      15           0 :         return;
      16             :     }
      17             : 
      18           2 :     snprintf( error->type, sizeof( error->type ), "%s", type );
      19           2 :     error->code = code;
      20             : 
      21             :     va_list args;
      22           2 :     va_start( args, format );
      23             : 
      24           2 :     vsnprintf( error->message, sizeof( error->message ), format, args );
      25           2 :     va_end( args );
      26             : }
      27             : 
      28           2 : bool error__equals( Error* first, Error* second ){
      29           2 :     if(
      30           2 :         strncmp( first->type, second->type, sizeof( first->type ) ) == 0 &&
      31           2 :         first->code == second->code
      32             :     ){
      33           1 :         return 1;
      34             :     }
      35             : 
      36           1 :     return 0;
      37             : }

Generated by: LCOV version 1.15