MINOR: sample: Don't check if argument list is set in sample fetches
The list is always defined by definition. Thus there is no reason to test
it.
diff --git a/src/sample.c b/src/sample.c
index bf2de2a..58c47ed 100644
--- a/src/sample.c
+++ b/src/sample.c
@@ -1599,7 +1599,7 @@
{
struct buffer *trash = get_trash_chunk();
int bits = 256;
- if (arg_p && arg_p->data.sint)
+ if (arg_p->data.sint)
bits = arg_p->data.sint;
switch (bits) {
@@ -1920,7 +1920,7 @@
{
smp->data.u.sint = hash_djb2(smp->data.u.str.area,
smp->data.u.str.data);
- if (arg_p && arg_p->data.sint)
+ if (arg_p->data.sint)
smp->data.u.sint = full_hash(smp->data.u.sint);
smp->data.type = SMP_T_SINT;
return 1;
@@ -2019,7 +2019,7 @@
{
smp->data.u.sint = hash_sdbm(smp->data.u.str.area,
smp->data.u.str.data);
- if (arg_p && arg_p->data.sint)
+ if (arg_p->data.sint)
smp->data.u.sint = full_hash(smp->data.u.sint);
smp->data.type = SMP_T_SINT;
return 1;
@@ -2056,7 +2056,7 @@
{
smp->data.u.sint = hash_wt6(smp->data.u.str.area,
smp->data.u.str.data);
- if (arg_p && arg_p->data.sint)
+ if (arg_p->data.sint)
smp->data.u.sint = full_hash(smp->data.u.sint);
smp->data.type = SMP_T_SINT;
return 1;
@@ -2069,7 +2069,7 @@
{
unsigned int seed;
- if (arg_p && arg_p->data.sint)
+ if (arg_p->data.sint)
seed = arg_p->data.sint;
else
seed = 0;
@@ -2089,7 +2089,7 @@
{
unsigned long long int seed;
- if (arg_p && arg_p->data.sint)
+ if (arg_p->data.sint)
seed = (unsigned long long int)arg_p->data.sint;
else
seed = 0;
@@ -2103,7 +2103,7 @@
{
unsigned long long int seed;
- if (arg_p && arg_p->data.sint)
+ if (arg_p->data.sint)
seed = (unsigned long long int)arg_p->data.sint;
else
seed = 0;
@@ -2118,7 +2118,7 @@
{
smp->data.u.sint = hash_crc32(smp->data.u.str.area,
smp->data.u.str.data);
- if (arg_p && arg_p->data.sint)
+ if (arg_p->data.sint)
smp->data.u.sint = full_hash(smp->data.u.sint);
smp->data.type = SMP_T_SINT;
return 1;
@@ -2129,7 +2129,7 @@
{
smp->data.u.sint = hash_crc32c(smp->data.u.str.area,
smp->data.u.str.data);
- if (arg_p && arg_p->data.sint)
+ if (arg_p->data.sint)
smp->data.u.sint = full_hash(smp->data.u.sint);
smp->data.type = SMP_T_SINT;
return 1;
@@ -2193,8 +2193,7 @@
unsigned int ret;
char *p;
- if (arg_p)
- input_type = arg_p->data.sint;
+ input_type = arg_p->data.sint;
temp = get_trash_chunk();
temp->data = 0;
@@ -2322,11 +2321,6 @@
{
struct arg *arg = args;
- if (!arg) {
- memprintf(err, "Unexpected empty arg list");
- return 0;
- }
-
if (arg->type != ARGT_SINT) {
memprintf(err, "Unexpected arg type");
return 0;
@@ -3543,7 +3537,7 @@
{
char *env;
- if (!args || args[0].type != ARGT_STR)
+ if (args[0].type != ARGT_STR)
return 0;
env = getenv(args[0].data.str.area);
@@ -3604,18 +3598,18 @@
smp->data.u.sint = date.tv_sec;
/* report in milliseconds */
- if (args && args[1].type == ARGT_SINT && args[1].data.sint == TIME_UNIT_MS) {
+ if (args[1].type == ARGT_SINT && args[1].data.sint == TIME_UNIT_MS) {
smp->data.u.sint *= 1000;
smp->data.u.sint += date.tv_usec / 1000;
}
/* report in microseconds */
- else if (args && args[1].type == ARGT_SINT && args[1].data.sint == TIME_UNIT_US) {
+ else if (args[1].type == ARGT_SINT && args[1].data.sint == TIME_UNIT_US) {
smp->data.u.sint *= 1000000;
smp->data.u.sint += date.tv_usec;
}
/* add offset */
- if (args && args[0].type == ARGT_SINT)
+ if (args[0].type == ARGT_SINT)
smp->data.u.sint += args[0].data.sint;
smp->data.type = SMP_T_SINT;
@@ -3681,7 +3675,7 @@
smp->data.u.sint = ha_random32();
/* reduce if needed. Don't do a modulo, use all bits! */
- if (args && args[0].type == ARGT_SINT)
+ if (args[0].type == ARGT_SINT)
smp->data.u.sint = ((u64)smp->data.u.sint * (u64)args[0].data.sint) >> 32;
smp->data.type = SMP_T_SINT;