本文整理汇总了C++中check_range函数的典型用法代码示例。如果您正苦于以下问题:C++ check_range函数的具体用法?C++ check_range怎么用?C++ check_range使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_range函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_integer
static long get_integer(char **ptr, long min, long max)
{
long val = min;
char *p = *ptr, *s;
if (volume_percent >= 0)
{
val = (int)(max * volume_percent / 100);
val = check_range(val, min, max);
return val;
}
if (*p == ':')
p++;
if (*p == '\0' || (!isdigit(*p) && *p != '-'))
goto out;
s = p;
val = strtol(s, &p, 10);
if (*p == '.')
{
p++;
strtol(p, &p, 10);
}
if (*p == '%')
{
val = (long)convert_prange1(strtod(s, NULL), min, max);
p++;
}
val = check_range(val, min, max);
if (*p == ',')
p++;
out:
*ptr = p;
return val;
}
示例2: verify
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (setting);
if (!priv->interface_name || !strlen(priv->interface_name)) {
g_set_error (error,
NM_SETTING_BRIDGE_ERROR,
NM_SETTING_BRIDGE_ERROR_MISSING_PROPERTY,
NM_SETTING_BRIDGE_INTERFACE_NAME);
return FALSE;
}
if (!nm_utils_iface_valid_name (priv->interface_name)) {
g_set_error (error,
NM_SETTING_BRIDGE_ERROR,
NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY,
NM_SETTING_BRIDGE_INTERFACE_NAME);
return FALSE;
}
if (!check_range (priv->forward_delay,
BR_MIN_FORWARD_DELAY,
BR_MAX_FORWARD_DELAY,
NM_SETTING_BRIDGE_FORWARD_DELAY,
error))
return FALSE;
if (!check_range (priv->hello_time,
BR_MIN_HELLO_TIME,
BR_MAX_HELLO_TIME,
NM_SETTING_BRIDGE_HELLO_TIME,
error))
return FALSE;
if (!check_range (priv->max_age,
BR_MIN_MAX_AGE,
BR_MAX_MAX_AGE,
NM_SETTING_BRIDGE_MAX_AGE,
error))
return FALSE;
if (!check_range (priv->ageing_time,
BR_MIN_AGEING_TIME,
BR_MAX_AGEING_TIME,
NM_SETTING_BRIDGE_AGEING_TIME,
error))
return FALSE;
return TRUE;
}
示例3: get_status
int
get_status (double value, thresholds * my_thresholds)
{
if (my_thresholds->critical != NULL)
{
if (check_range (value, my_thresholds->critical) == TRUE)
return STATE_CRITICAL;
}
if (my_thresholds->warning != NULL)
{
if (check_range (value, my_thresholds->warning) == TRUE)
return STATE_WARNING;
}
return STATE_OK;
}
示例4: stress_set_bsearch_size
/*
* stress_set_bsearch_size()
* set bsearch size from given option string
*/
void stress_set_bsearch_size(const char *optarg)
{
set_bsearch_size = true;
opt_bsearch_size = get_uint64_byte(optarg);
check_range("bsearch-size", opt_bsearch_size,
MIN_BSEARCH_SIZE, MAX_BSEARCH_SIZE);
}
示例5: run_teacher_task
static int run_teacher_task ( void )
{
if (startFlag==1)
{
temp_time1 = gettime();
startFlag=0;
}
temp_time2 = gettime();
if ((temp_time2-temp_time1)/1000.0 > 2.0) //save teach-data every 10 ms
{
startFlag=1;
saveUnifyData(); // save vision data and joint state
//saveJoint_state(1, 1, 1, 1, 1, 1); // save jointPos,jointVel,jointAcc:(actual and desired); save cartpos,vel,acc:(actual);
}
int i = 0;
for ( i = 1; i <= N_DOFS; i++ )
{
joint_des_state[i].th = joint_state[i].th+joint_state[i].thd/task_servo_rate; //+joint_state[i].thdd/task_servo_rate/task_servo_rate;
joint_des_state[i].thd = 0.0;
joint_des_state[i].thdd = 0.0;
joint_des_state[i].uff = 0.0;
}
SL_InvDyn( NULL, joint_des_state, endeff, &base_state, &base_orient );
check_range( joint_des_state );
return TRUE;
}
示例6: da9034_set_dvc_voltage
/* DA9034 specific operations */
static int da9034_set_dvc_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
struct device *da9034_dev = to_da903x_dev(rdev);
uint8_t val, mask;
int ret;
if (check_range(info, min_uV, max_uV)) {
pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
return -EINVAL;
}
val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
ret = da903x_update(da9034_dev, info->vol_reg, val, mask);
if (ret)
return ret;
ret = da903x_set_bits(da9034_dev, info->update_reg,
1 << info->update_bit);
return ret;
}
示例7: stress_set_bigheap_growth
/*
* stress_set_bigheap_growth()
* Set bigheap growth from given opt arg string
*/
void stress_set_bigheap_growth(const char *optarg)
{
set_bigheap_growth = true;
opt_bigheap_growth = get_uint64_byte(optarg);
check_range("bigheap-growth", opt_bigheap_growth,
MIN_BIGHEAP_GROWTH, MAX_BIGHEAP_GROWTH);
}
示例8: stress_set_vm_rw_bytes
void stress_set_vm_rw_bytes(const char *optarg)
{
set_vm_rw_bytes = true;
opt_vm_rw_bytes = (size_t)get_uint64_byte(optarg);
check_range("vm-rw-bytes", opt_vm_rw_bytes,
MIN_VM_RW_BYTES, MAX_VM_RW_BYTES);
}
示例9: da9030_set_ldo1_15_voltage
/* DA9030 specific operations */
static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
struct device *da903x_dev = to_da903x_dev(rdev);
uint8_t val, mask;
int ret;
if (check_range(info, min_uV, max_uV)) {
pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
return -EINVAL;
}
val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
val |= DA9030_LDO_UNLOCK; /* have to set UNLOCK bits */
mask |= DA9030_LDO_UNLOCK_MASK;
/* write twice */
ret = da903x_update(da903x_dev, info->vol_reg, val, mask);
if (ret)
return ret;
return da903x_update(da903x_dev, info->vol_reg, val, mask);
}
示例10: gx_concretize_CIEABC
int
gx_concretize_CIEABC(const gs_client_color * pc, const gs_color_space * pcs_in,
frac * pconc, const gs_imager_state * pis, gx_device *dev)
{
gs_color_space *pcs_icc;
gs_client_color scale_pc;
bool islab;
gs_color_space *pcs = (gs_color_space *) pcs_in;
if_debug3('c', "[c]concretize CIEABC [%g %g %g]\n",
pc->paint.values[0], pc->paint.values[1],
pc->paint.values[2]);
/* If we are comming in here then we have not completed
the conversion of the ABC space to an ICC type. We
will finish that process now. */
if (pcs->icc_equivalent == NULL) {
gx_cieabc_to_icc(&pcs_icc, pcs, &islab, pis->memory->stable_memory);
} else {
pcs_icc = pcs->icc_equivalent;
}
/* Rescale the input based upon the input range since profile is
created to remap this range from 0 to 1 */
if (check_range(&(pcs->params.abc->RangeABC.ranges[0]), 3)) {
return((pcs_icc->type->concretize_color)(pc, pcs_icc, pconc, pis, dev));
}
/* Do the rescale from 0 to 1 */
rescale_input_color(&(pcs->params.abc->RangeABC.ranges[0]), 3, pc, &scale_pc);
/* Now the icc remap */
return((pcs_icc->type->concretize_color)(&scale_pc, pcs_icc, pconc, pis, dev));
}
示例11: axp_set_ldo4_voltage
static int axp_set_ldo4_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV, unsigned *selector)
{
struct axp_regulator_info *info = rdev_get_drvdata(rdev);
struct device *axp_dev = to_axp_dev(rdev);
uint8_t val, mask;
int i;
if (check_range(info, min_uV, max_uV)) {
pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
return -EINVAL;
}
for(i = 0,val = 0; i < sizeof(axp_ldo4_data);i++){
if(min_uV <= axp_ldo4_data[i] * 1000){
val = i;
break;
}
}
*selector = val;
val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
return axp_update(axp_dev, info->vol_reg, val, mask);
}
示例12: gx_concretize_CIEDEF
/* Render a CIEBasedDEF color. */
int
gx_concretize_CIEDEF(const gs_client_color * pc, const gs_color_space * pcs_in,
frac * pconc, const gs_imager_state * pis, gx_device *dev)
{
int code = 0;
gs_color_space *pcs_icc;
gs_client_color scale_pc;
gs_color_space *pcs = (gs_color_space *) pcs_in;
if_debug3m('c', pis->memory, "[c]concretize DEF [%g %g %g]\n",
pc->paint.values[0], pc->paint.values[1],
pc->paint.values[2]);
/* If we are comming in here then we have not completed
the conversion of the DEF space to an ICC type. We
will finish that process now. */
if (pcs->icc_equivalent == NULL) {
code = gx_ciedef_to_icc(&pcs_icc, pcs, pis->memory->stable_memory);
if (code < 0)
return gs_rethrow(code, "Failed to build ICC profile from CIEDEF");
} else {
pcs_icc = pcs->icc_equivalent;
}
/* Rescale the input based upon the input range since profile is
created to remap this range from 0 to 1 */
if (check_range(&(pcs->params.def->RangeDEF.ranges[0]), 3)) {
return (pcs_icc->type->concretize_color)(pc, pcs_icc, pconc, pis, dev);
}
/* Do the rescale from 0 to 1 */
rescale_input_color(&(pcs->params.def->RangeDEF.ranges[0]), 3, pc, &scale_pc);
/* Now the icc remap */
return (pcs_icc->type->concretize_color)(&scale_pc, pcs_icc, pconc, pis, dev);
}
示例13: check_cie_range
/* Returns false if range is not 0 1 */
bool
check_cie_range( const gs_color_space * pcs )
{
switch(gs_color_space_get_index(pcs)){
case gs_color_space_index_CIEDEFG:
return(check_range(&(pcs->params.defg->RangeDEFG.ranges[0]), 4));
case gs_color_space_index_CIEDEF:
return(check_range(&(pcs->params.def->RangeDEF.ranges[0]), 3));
case gs_color_space_index_CIEABC:
return(check_range(&(pcs->params.abc->RangeABC.ranges[0]), 3));
case gs_color_space_index_CIEA:
return(check_range(&(pcs->params.a->RangeA), 1));
default:
return true;
}
}
示例14: stress_set_vm_splice_bytes
void stress_set_vm_splice_bytes(const char *optarg)
{
set_vm_splice_bytes = true;
opt_vm_splice_bytes = (size_t)get_uint64_byte(optarg);
check_range("vm-splice-bytes", opt_vm_splice_bytes,
MIN_VM_SPLICE_BYTES, MAX_VM_SPLICE_BYTES);
}
示例15: get_integer64
static long long get_integer64(const char **ptr, long long min, long long max)
{
long long val = min;
char *p = (char *)*ptr, *s;
if (*p == ':')
p++;
if (*p == '\0' || (!isdigit(*p) && *p != '-'))
goto out;
s = p;
val = strtol(s, &p, 0);
if (*p == '.') {
p++;
(void)strtol(p, &p, 10);
}
if (*p == '%') {
val = (long long)convert_prange1(strtod(s, NULL), min, max);
p++;
}
val = check_range(val, min, max);
if (*p == ',')
p++;
out:
*ptr = p;
return val;
}