diff mbox series

[bpf-next,2/4] bpf/verifier: fix code formatting

Message ID 20190301013716.1370014-3-andriin@fb.com
State Changes Requested
Delegated to: BPF Maintainers
Headers show
Series Formatting and typo fixes in kernel/bpf | expand

Commit Message

Andrii Nakryiko March 1, 2019, 1:37 a.m. UTC
Fix few formatting problems.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 kernel/bpf/verifier.c | 66 +++++++++++++++++++++----------------------
 1 file changed, 33 insertions(+), 33 deletions(-)

Comments

Alexei Starovoitov March 1, 2019, 7:23 p.m. UTC | #1
On 2/28/19 5:37 PM, Andrii Nakryiko wrote:
> -#define REALLOC_STATE_FN(NAME, COUNT, FIELD, SIZE)			\
> -static int realloc_##NAME##_state(struct bpf_func_state *state, int size, \
> -				  bool copy_old)			\
> -{									\
> -	u32 old_size = state->COUNT;					\
> -	struct bpf_##NAME##_state *new_##FIELD;				\
> -	int slot = size / SIZE;						\
> -									\
> -	if (size <= old_size || !size) {				\
> -		if (copy_old)						\
> -			return 0;					\
> -		state->COUNT = slot * SIZE;				\
> -		if (!size && old_size) {				\
> -			kfree(state->FIELD);				\
> -			state->FIELD = NULL;				\
> -		}							\
> -		return 0;						\
> -	}								\
> +#define REALLOC_STATE_FN(NAME, COUNT, FIELD, SIZE)			     \
> +static int realloc_##NAME##_state(struct bpf_func_state *state, int size,    \
> +				  bool copy_old)			     \
> +{									     \
> +	u32 old_size = state->COUNT;					     \

what is the change here?
extra tab at the end of every line?
I think that adds too much noise to git history.
I'd rather keep this bit as-is.
Andrii Nakryiko March 2, 2019, 10:02 p.m. UTC | #2
On Fri, Mar 1, 2019 at 11:24 AM Alexei Starovoitov <ast@fb.com> wrote:
>
> On 2/28/19 5:37 PM, Andrii Nakryiko wrote:
> > -#define REALLOC_STATE_FN(NAME, COUNT, FIELD, SIZE)                   \
> > -static int realloc_##NAME##_state(struct bpf_func_state *state, int size, \
> > -                               bool copy_old)                        \
> > -{                                                                    \
> > -     u32 old_size = state->COUNT;                                    \
> > -     struct bpf_##NAME##_state *new_##FIELD;                         \
> > -     int slot = size / SIZE;                                         \
> > -                                                                     \
> > -     if (size <= old_size || !size) {                                \
> > -             if (copy_old)                                           \
> > -                     return 0;                                       \
> > -             state->COUNT = slot * SIZE;                             \
> > -             if (!size && old_size) {                                \
> > -                     kfree(state->FIELD);                            \
> > -                     state->FIELD = NULL;                            \
> > -             }                                                       \
> > -             return 0;                                               \
> > -     }                                                               \
> > +#define REALLOC_STATE_FN(NAME, COUNT, FIELD, SIZE)                        \
> > +static int realloc_##NAME##_state(struct bpf_func_state *state, int size,    \
> > +                               bool copy_old)                             \
> > +{                                                                         \
> > +     u32 old_size = state->COUNT;                                         \
>
> what is the change here?
> extra tab at the end of every line?
> I think that adds too much noise to git history.
> I'd rather keep this bit as-is.
>
>

I feel like this whole patchset doesn't add much value and will just
pollute history. I'm just going to abandon it for now.
diff mbox series

Patch

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 0e4edd7e3c5f..c09ec3222d13 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -389,7 +389,7 @@  static bool is_release_function(enum bpf_func_id func_id)
 static bool is_acquire_function(enum bpf_func_id func_id)
 {
 	return func_id == BPF_FUNC_sk_lookup_tcp ||
-		func_id == BPF_FUNC_sk_lookup_udp;
+	       func_id == BPF_FUNC_sk_lookup_udp;
 }
 
 /* string representation of 'enum bpf_reg_type' */
@@ -559,39 +559,39 @@  COPY_STATE_FN(reference, acquired_refs, refs, 1)
 COPY_STATE_FN(stack, allocated_stack, stack, BPF_REG_SIZE)
 #undef COPY_STATE_FN
 
-#define REALLOC_STATE_FN(NAME, COUNT, FIELD, SIZE)			\
-static int realloc_##NAME##_state(struct bpf_func_state *state, int size, \
-				  bool copy_old)			\
-{									\
-	u32 old_size = state->COUNT;					\
-	struct bpf_##NAME##_state *new_##FIELD;				\
-	int slot = size / SIZE;						\
-									\
-	if (size <= old_size || !size) {				\
-		if (copy_old)						\
-			return 0;					\
-		state->COUNT = slot * SIZE;				\
-		if (!size && old_size) {				\
-			kfree(state->FIELD);				\
-			state->FIELD = NULL;				\
-		}							\
-		return 0;						\
-	}								\
+#define REALLOC_STATE_FN(NAME, COUNT, FIELD, SIZE)			     \
+static int realloc_##NAME##_state(struct bpf_func_state *state, int size,    \
+				  bool copy_old)			     \
+{									     \
+	u32 old_size = state->COUNT;					     \
+	struct bpf_##NAME##_state *new_##FIELD;				     \
+	int slot = size / SIZE;						     \
+									     \
+	if (size <= old_size || !size) {				     \
+		if (copy_old)						     \
+			return 0;					     \
+		state->COUNT = slot * SIZE;				     \
+		if (!size && old_size) {				     \
+			kfree(state->FIELD);				     \
+			state->FIELD = NULL;				     \
+		}							     \
+		return 0;						     \
+	}								     \
 	new_##FIELD = kmalloc_array(slot, sizeof(struct bpf_##NAME##_state), \
-				    GFP_KERNEL);			\
-	if (!new_##FIELD)						\
-		return -ENOMEM;						\
-	if (copy_old) {							\
-		if (state->FIELD)					\
-			memcpy(new_##FIELD, state->FIELD,		\
-			       sizeof(*new_##FIELD) * (old_size / SIZE)); \
-		memset(new_##FIELD + old_size / SIZE, 0,		\
-		       sizeof(*new_##FIELD) * (size - old_size) / SIZE); \
-	}								\
-	state->COUNT = slot * SIZE;					\
-	kfree(state->FIELD);						\
-	state->FIELD = new_##FIELD;					\
-	return 0;							\
+				    GFP_KERNEL);			     \
+	if (!new_##FIELD)						     \
+		return -ENOMEM;						     \
+	if (copy_old) {							     \
+		if (state->FIELD)					     \
+			memcpy(new_##FIELD, state->FIELD,		     \
+			       sizeof(*new_##FIELD) * (old_size / SIZE));    \
+		memset(new_##FIELD + old_size / SIZE, 0,		     \
+		       sizeof(*new_##FIELD) * (size - old_size) / SIZE);     \
+	}								     \
+	state->COUNT = slot * SIZE;					     \
+	kfree(state->FIELD);						     \
+	state->FIELD = new_##FIELD;					     \
+	return 0;							     \
 }
 /* realloc_reference_state() */
 REALLOC_STATE_FN(reference, acquired_refs, refs, 1)