@@ -452,6 +452,8 @@ ioctl_record_open(int fd)
452452
453453 /* lazily open the record file */
454454 if (ioctl_record_log == NULL ) {
455+ int r ;
456+
455457 const char * path = getenv ("UMOCKDEV_IOCTL_RECORD_FILE" );
456458 const char * device_path = getenv ("UMOCKDEV_IOCTL_RECORD_DEVICE_PATH" );
457459 struct sigaction act_int ;
@@ -514,9 +516,11 @@ ioctl_record_open(int fd)
514516
515517 /* ensure that we write the file also on Control-C */
516518 act_int .sa_handler = ioctl_record_sigint_handler ;
517- assert (sigemptyset (& act_int .sa_mask ) == 0 );
519+ r = sigemptyset (& act_int .sa_mask );
520+ assert (r == 0 );
518521 act_int .sa_flags = 0 ;
519- assert (sigaction (SIGINT , & act_int , & orig_actint ) == 0 );
522+ r = sigaction (SIGINT , & act_int , & orig_actint );
523+ assert (r == 0 );
520524
521525 DBG (DBG_IOCTL , "ioctl_record_open: starting ioctl recording of fd %i into %s\n" , fd , path );
522526 } else {
@@ -535,8 +539,11 @@ ioctl_record_close(int fd)
535539
536540 /* recorded anything? */
537541 if (ioctl_record != NULL ) {
542+ int r ;
543+
538544 rewind (ioctl_record_log );
539- assert (ftruncate (fileno (ioctl_record_log ), 0 ) == 0 );
545+ r = ftruncate (fileno (ioctl_record_log ), 0 );
546+ assert (r == 0 );
540547 fprintf (ioctl_record_log , "@DEV %s\n" , getenv ("UMOCKDEV_IOCTL_RECORD_DEVICE_PATH" ));
541548 ioctl_tree_write (ioctl_record_log , ioctl_record );
542549 fflush (ioctl_record_log );
@@ -545,9 +552,12 @@ ioctl_record_close(int fd)
545552
546553static void ioctl_record_sigint_handler (int signum )
547554{
555+ int r ;
556+
548557 DBG (DBG_IOCTL , "ioctl_record_sigint_handler: got signal %i, flushing record\n" , signum );
549558 ioctl_record_close (ioctl_record_fd );
550- assert (sigaction (SIGINT , & orig_actint , NULL ) == 0 );
559+ r = sigaction (SIGINT , & orig_actint , NULL );
560+ assert (r == 0 );
551561 raise (signum );
552562}
553563
@@ -851,7 +861,10 @@ script_start_record(int fd, const char *logname, const char *recording_path, enu
851861
852862 srinfo = malloc (sizeof (struct script_record_info ));
853863 srinfo -> log = log ;
854- assert (clock_gettime (CLOCK_MONOTONIC , & srinfo -> time ) == 0 );
864+ if (clock_gettime (CLOCK_MONOTONIC , & srinfo -> time ) < 0 ) {
865+ fprintf (stderr , "libumockdev-preload: failed to clock_gettime: %m\n" );
866+ abort ();
867+ }
855868 srinfo -> op = 0 ;
856869 srinfo -> fmt = fmt ;
857870 fd_map_add (& script_recorded_fds , fd , srinfo );
@@ -861,9 +874,10 @@ static void
861874script_record_open (int fd )
862875{
863876 dev_t fd_dev ;
864- const char * logname , * recording_path ;
865- const void * data ;
877+ const char * logname , * recording_path = NULL ;
878+ const void * data = NULL ;
866879 enum script_record_format fmt ;
880+ int r ;
867881
868882 if (!script_dev_logfile_map_inited )
869883 init_script_dev_logfile_map ();
@@ -874,8 +888,10 @@ script_record_open(int fd)
874888 DBG (DBG_SCRIPT , "script_record_open: fd %i on device %i:%i is not recorded\n" , fd , major (fd_dev ), minor (fd_dev ));
875889 return ;
876890 }
877- assert (fd_map_get (& script_dev_devpath_map , fd_dev , (const void * * )& recording_path ));
878- assert (fd_map_get (& script_dev_format_map , fd_dev , & data ));
891+ r = fd_map_get (& script_dev_devpath_map , fd_dev , (const void * * )& recording_path );
892+ assert (r );
893+ r = fd_map_get (& script_dev_format_map , fd_dev , & data );
894+ assert (r );
879895 fmt = (enum script_record_format ) data ;
880896
881897 DBG (DBG_SCRIPT , "script_record_open: start recording fd %i on device %i:%i into %s (format %i)\n" ,
@@ -924,7 +940,10 @@ update_msec(struct timespec *tm)
924940{
925941 struct timespec now ;
926942 long delta ;
927- assert (clock_gettime (CLOCK_MONOTONIC , & now ) == 0 );
943+ if (clock_gettime (CLOCK_MONOTONIC , & now ) < 0 ) {
944+ fprintf (stderr , "libumockdev-preload: failed to clock_gettime: %m\n" );
945+ abort ();
946+ }
928947 delta = (now .tv_sec - tm -> tv_sec ) * 1000 + now .tv_nsec / 1000000 - tm -> tv_nsec / 1000000 ;
929948 assert (delta >= 0 );
930949 * tm = now ;
@@ -940,7 +959,7 @@ script_record_op(char op, int fd, const void *buf, ssize_t size)
940959 libc_func (fwrite , size_t , const void * , size_t , size_t , FILE * );
941960 static char header [100 ];
942961 const unsigned char * cur ;
943- int i ;
962+ int i , r ;
944963
945964 if (!fd_map_get (& script_recorded_fds , fd , (const void * * )& srinfo ))
946965 return ;
@@ -959,7 +978,8 @@ script_record_op(char op, int fd, const void *buf, ssize_t size)
959978 if (srinfo -> op != 0 )
960979 putc ('\n' , srinfo -> log );
961980 snprintf (header , sizeof (header ), "%c %lu " , op , delta );
962- assert (_fwrite (header , strlen (header ), 1 , srinfo -> log ) == 1 );
981+ r = _fwrite (header , strlen (header ), 1 , srinfo -> log );
982+ assert (r == 1 );
963983 }
964984
965985 /* escape ASCII control chars */
0 commit comments