mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-10-29 05:40:27 -04:00 
			
		
		
		
	*: rely on checks now done by spa_pod_get_values()
Rely on spa_pod_get_values() to return no values if the size is too small for the type. This means that if there is a check that at least one value is returned, checking that the size is large enough is unnecessary.
This commit is contained in:
		
							parent
							
								
									42098fd8c1
								
							
						
					
					
						commit
						5853e1150b
					
				
					 5 changed files with 7 additions and 13 deletions
				
			
		|  | @ -2255,7 +2255,7 @@ static int vidioc_queryctrl(struct file *file, struct v4l2_queryctrl *arg) | |||
| 
 | ||||
| 			// check type and populate range
 | ||||
| 			pod = spa_pod_get_values(type, &n_vals, &choice); | ||||
| 			if (spa_pod_is_int(pod)) { | ||||
| 			if (pod->type == SPA_TYPE_Int) { | ||||
| 				if (n_vals < 4) | ||||
| 					break; | ||||
| 				arg->type = V4L2_CTRL_TYPE_INTEGER; | ||||
|  | @ -2330,7 +2330,7 @@ static int vidioc_g_ctrl(struct file *file, struct v4l2_control *arg) | |||
| 		if (ctrl_id == arg->id) { | ||||
| 			// TODO: support getting true ctrl values instead of defaults
 | ||||
| 			pod = spa_pod_get_values(type, &n_vals, &choice); | ||||
| 			if (spa_pod_is_int(pod)) { | ||||
| 			if (pod->type == SPA_TYPE_Int) { | ||||
| 				if (n_vals < 4) | ||||
| 					break; | ||||
| 				int *v = SPA_POD_BODY(pod); | ||||
|  |  | |||
|  | @ -164,8 +164,7 @@ SPA_API_DEBUG_FORMAT int spa_debugc_format(struct spa_debug_context *ctx, int in | |||
| 		type = val->type; | ||||
| 		size = val->size; | ||||
| 
 | ||||
| 		if (type < SPA_TYPE_None || type >= _SPA_TYPE_LAST || n_vals < 1 || | ||||
| 		    size < spa_pod_type_size(type)) | ||||
| 		if (type < SPA_TYPE_None || type >= _SPA_TYPE_LAST || n_vals < 1) | ||||
| 			continue; | ||||
| 
 | ||||
| 		vals = SPA_POD_BODY(val); | ||||
|  |  | |||
|  | @ -82,7 +82,7 @@ spa_pod_filter_prop(struct spa_pod_builder *b, | |||
| 	v1 = spa_pod_get_values(&p1->value, &nalt1, &p1c); | ||||
| 	v2 = spa_pod_get_values(&p2->value, &nalt2, &p2c); | ||||
| 
 | ||||
| 	/* empty choices */ | ||||
| 	/* empty or bogus choices */ | ||||
| 	if (nalt1 < 1 || nalt2 < 1) | ||||
| 		return -EINVAL; | ||||
| 
 | ||||
|  | @ -95,8 +95,6 @@ spa_pod_filter_prop(struct spa_pod_builder *b, | |||
| 	/* incompatible property types */ | ||||
| 	if (type != v2->type || size != v2->size || p1->key != p2->key) | ||||
| 		return -EINVAL; | ||||
| 	if (size < spa_pod_type_size(type)) | ||||
| 		return -EINVAL; | ||||
| 
 | ||||
| 	/* start with copying the property */ | ||||
| 	spa_pod_builder_prop(b, p1->key, p1->flags & p2->flags); | ||||
|  | @ -405,7 +403,7 @@ SPA_API_POD_FILTER int spa_pod_filter_object_make(struct spa_pod_object *pod) | |||
| 			struct spa_pod *v = spa_pod_get_values(&res->value, &nvals, &choice); | ||||
| 			const void *vals = SPA_POD_BODY(v); | ||||
| 
 | ||||
| 			if (v->size < spa_pod_type_size(v->type)) | ||||
| 			if (nvals < 1) | ||||
| 				continue; | ||||
| 
 | ||||
| 			if (spa_pod_compare_is_valid_choice(v->type, v->size, | ||||
|  |  | |||
|  | @ -1209,10 +1209,7 @@ static struct spa_pod *transform_format(struct impl *this, struct port *port, co | |||
| 			uint32_t n_vals, choice, *id_vals; | ||||
| 			struct spa_pod *val = spa_pod_get_values(&prop->value, &n_vals, &choice); | ||||
| 
 | ||||
| 			if (n_vals < 1) | ||||
| 				return 0; | ||||
| 
 | ||||
| 			if (!spa_pod_is_id(val)) | ||||
| 			if (n_vals < 1 || val->type != SPA_TYPE_Id) | ||||
| 				return 0; | ||||
| 
 | ||||
| 			id_vals = SPA_POD_BODY(val); | ||||
|  |  | |||
|  | @ -683,7 +683,7 @@ static int add_int(struct format_info *info, const char *k, struct spa_pod *para | |||
| 		return -ENOENT; | ||||
| 
 | ||||
| 	val = spa_pod_get_values(&prop->value, &n_values, &choice); | ||||
| 	if (!spa_pod_is_int(val)) | ||||
| 	if (val->type != SPA_TYPE_Int) | ||||
| 		return -ENOTSUP; | ||||
| 
 | ||||
| 	if (n_values == 0) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Demi Marie Obenour
						Demi Marie Obenour