title: Declared with attribute warn_unused_result [-Wunused-result]
body: <p>I compiled the code below using Ideone.com and the following warning popped up.</p>
  
  <pre><code>rtctimer.c: In function 'rtctimer_next_tick':
  rtctimer.c:87.7: warning: ignoring return value of 'read', 
                   declared with attribute warn_unused_result [-Wunused-result]
  </code></pre>
  
  
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;poll.h&gt;
  #include &lt;sched.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;math.h&gt;
  #include &lt;sys/ioctl.h&gt;
  #include &lt;linux/rtc.h&gt;
  #include "rtctimer.h"
  
  struct rtctimer_s
  {
      int rtc_fd;
      int current_hz;
      int rtc_running;
      int verbose;
      int usecs;
  };
  
  rtctimer_t *rtctimer_new( int verbose )
  {
      rtctimer_t *rtctimer = malloc( sizeof( rtctimer_t ) );
      if( !rtctimer ) return 0;
  
      rtctimer-&gt;verbose = verbose;
      if( (( rtctimer-&gt;rtc_fd = open( "/dev/rtc", O_RDONLY ) ) &lt; 0) ) {
          if( rtctimer-&gt;verbose ) {
              fprintf( stderr, "rtctimer: Cannot open /dev/rtc: %s\n",
                       strerror( errno ) );
          }
          if( ( rtctimer-&gt;rtc_fd = open( "/dev/misc/rtc", O_RDONLY ) ) &lt; 0 ) {
              if( rtctimer-&gt;verbose ) {
                  fprintf( stderr, "rtctimer: Cannot open /dev/misc/rtc: %s\n",
                           strerror( errno ) );
              }
              free( rtctimer );
              return 0;
          }
      }
  
      if( fcntl( rtctimer-&gt;rtc_fd, F_SETOWN, getpid() ) &lt; 0 ) {
          if( rtctimer-&gt;verbose ) {
              fprintf( stderr, "rtctimer: Cannot set ownership of "
                               "/dev/rtc: %s\n", strerror( errno ) );
          }
          close( rtctimer-&gt;rtc_fd );
          free( rtctimer );
          return 0;
      }
  
      rtctimer-&gt;rtc_running = 0;
      rtctimer-&gt;current_hz = 0;
      rtctimer-&gt;usecs = 0;
      return rtctimer;
  }
  
  void rtctimer_delete( rtctimer_t *rtctimer )
  {
      rtctimer_stop_clock( rtctimer );
      close( rtctimer-&gt;rtc_fd );
      free( rtctimer );
  }
  
  int rtctimer_next_tick( rtctimer_t *rtctimer )
  {
      unsigned long rtc_data;
      struct pollfd pfd;
      pfd.fd = rtctimer-&gt;rtc_fd;
      pfd.events = POLLIN | POLLERR;
  
  again:
      if( poll( &amp;pfd, 1, 100000 ) &lt; 0 ) {
          if( errno == EINTR ) {
              goto again;
          }
  
          if( rtctimer-&gt;verbose ) {
              fprintf( stderr, "rtctimer: poll call failed: %s\n",
                       strerror( errno ) );
          }
          return 0;
      }
  
      read( rtctimer-&gt;rtc_fd, &amp;rtc_data, sizeof( rtc_data ) );
      return 1;
  }
  
  int rtctimer_set_interval( rtctimer_t *rtctimer, int hz )
  {
      int restart;
  
      if( hz == rtctimer-&gt;current_hz ) {
          return 1;
      }
  
      restart = rtctimer_stop_clock( rtctimer );
  
      if( ioctl( rtctimer-&gt;rtc_fd, RTC_IRQP_SET, hz ) &lt; 0 ) {
          if( rtctimer-&gt;verbose ) {
              fprintf( stderr, "rtctimer: Cannot set periodic interval: %s\n",
                       strerror( errno ) );
          }
          return 0;
      }
  
      rtctimer-&gt;current_hz = hz;
      rtctimer-&gt;usecs = (int) ( ( ( 1000.0 * 1000.0 ) / hz ) + 0.5 );
  
      if( restart ) {
          rtctimer_start_clock( rtctimer );
      }
  
      return 1;
  }
  
  int rtctimer_start_clock( rtctimer_t *rtctimer )
  {
      if( !rtctimer-&gt;rtc_running ) {
          if( ioctl( rtctimer-&gt;rtc_fd, RTC_PIE_ON, 0 ) &lt; 0 ) {
              if( rtctimer-&gt;verbose ) {
                  fprintf( stderr, "rtctimer: Cannot start periodic "
                           "interrupts: %s\n", strerror( errno ) );
              }
              return 0;
          }
          rtctimer-&gt;rtc_running = 1;
      }
      return rtctimer-&gt;rtc_running;
  }
  
  int rtctimer_stop_clock( rtctimer_t *rtctimer )
  {
      int was_running = rtctimer-&gt;rtc_running;
  
      if( rtctimer-&gt;rtc_running ) {
          if( ioctl( rtctimer-&gt;rtc_fd, RTC_PIE_OFF, 0 ) &lt; 0 ) {
              if( rtctimer-&gt;verbose ) {
                  fprintf( stderr, "rtctimer: Cannot stop periodic "
                           "interrupts: %s\n", strerror( errno ) );
              }
              return rtctimer-&gt;rtc_running;
          }
          rtctimer-&gt;rtc_running = 0;
      }
  
      return was_running;
  }
  
  int rtctimer_get_resolution( rtctimer_t *rtctimer )
  {
      return rtctimer-&gt;current_hz;
  }
  
  int rtctimer_get_usecs( rtctimer_t *rtctimer )
  {
      return rtctimer-&gt;usecs;
  }
  
  int set_realtime_priority( int max )
  {
      struct sched_param schp;
  
      memset( &amp;schp, 0, sizeof( schp ) );
      if( max ) schp.sched_priority = sched_get_priority_max( SCHED_FIFO );
      else schp.sched_priority = sched_get_priority_max( SCHED_FIFO ) - 1;
  
      if( sched_setscheduler( 0, SCHED_FIFO, &amp;schp ) != 0 ) {
          return 0;
      }
  
      return 1;
  }
  
  int set_default_priority( void )
  {
      struct sched_param schp;
  
      memset( &amp;schp, 0, sizeof( schp ) );
      schp.sched_priority = 0;
      if( sched_setscheduler( 0, SCHED_OTHER, &amp;schp ) != 0 ) {
          return 0;
      }
  
      return 1;
  }
  </code></pre>
  
  <p>What did I do wrong?</p>