filters/blocksize/blocksize.c
/* Check that limits are sane. */
Check that limits are sane.
Check that limits are sane .
static int
blocksize_config_complete (nbdkit_next_config_complete *next, void *nxdata)
{
  if (minblock) {
    if (minblock & (minblock - 1)) {
      nbdkit_error ("minblock must be a power of 2");
      return -1;
    }
    if (minblock > BLOCKSIZE_MIN_LIMIT) {
      nbdkit_error ("minblock must not exceed %u", BLOCKSIZE_MIN_LIMIT);
      return -1;
    }
  }
  else
    minblock = 1;
  if (maxdata) {
    if (maxdata & (minblock - 1)) {
      nbdkit_error ("maxdata must be a multiple of %u", minblock);
      return -1;
    }
  }
  else if (maxlen)
    maxdata = MIN (maxlen, 64 * 1024 * 1024);
  else
    maxdata = 64 * 1024 * 1024;
  if (maxlen) {
    if (maxlen & (minblock - 1)) {
      nbdkit_error ("maxlen must be a multiple of %u", minblock);
      return -1;
    }
  }
  else
    maxlen = -minblock;
  return next (nxdata);
}
static int blocksize_config_complete ( nbdkit_next_config_complete * next , void * nxdata ) { if ( minblock ) { if ( minblock & ( minblock - 1 ) ) { nbdkit_error ( " " ) ; return -1 ; } if ( minblock > BLOCKSIZE_MIN_LIMIT ) { nbdkit_error ( " " , BLOCKSIZE_MIN_LIMIT ) ; return -1 ; } } else minblock = 1 ; if ( maxdata ) { if ( maxdata & ( minblock - 1 ) ) { nbdkit_error ( " " , minblock ) ; return -1 ; } } else if ( maxlen ) maxdata = MIN ( maxlen , 64 * 1024 * 1024 ) ; else maxdata = 64 * 1024 * 1024 ; if ( maxlen ) { if ( maxlen & ( minblock - 1 ) ) { nbdkit_error ( " " , minblock ) ; return -1 ; } } else maxlen = - minblock ; return next ( nxdata ) ; }
Check that limits are sane.
Check that limits are sane .