@@ -2076,40 +2076,40 @@ void
2076
2076
vchiq_dump (void * dump_context , const char * str , int len )
2077
2077
{
2078
2078
struct dump_context * context = (struct dump_context * )dump_context ;
2079
+ int copy_bytes ;
2079
2080
2080
- if (context -> actual < context -> space ) {
2081
- int copy_bytes ;
2081
+ if (context -> actual >= context -> space )
2082
+ return ;
2082
2083
2083
- if (context -> offset > 0 ) {
2084
- int skip_bytes = min_t (int , len , context -> offset );
2084
+ if (context -> offset > 0 ) {
2085
+ int skip_bytes = min_t (int , len , context -> offset );
2085
2086
2086
- str += skip_bytes ;
2087
- len -= skip_bytes ;
2088
- context -> offset -= skip_bytes ;
2089
- if (context -> offset > 0 )
2090
- return ;
2091
- }
2092
- copy_bytes = min_t (int , len , context -> space - context -> actual );
2093
- if (copy_bytes == 0 )
2087
+ str += skip_bytes ;
2088
+ len -= skip_bytes ;
2089
+ context -> offset -= skip_bytes ;
2090
+ if (context -> offset > 0 )
2094
2091
return ;
2095
- if (copy_to_user (context -> buf + context -> actual , str ,
2096
- copy_bytes ))
2092
+ }
2093
+ copy_bytes = min_t (int , len , context -> space - context -> actual );
2094
+ if (copy_bytes == 0 )
2095
+ return ;
2096
+ if (copy_to_user (context -> buf + context -> actual , str ,
2097
+ copy_bytes ))
2098
+ context -> actual = - EFAULT ;
2099
+ context -> actual += copy_bytes ;
2100
+ len -= copy_bytes ;
2101
+
2102
+ /*
2103
+ * If the terminating NUL is included in the length, then it
2104
+ * marks the end of a line and should be replaced with a
2105
+ * carriage return.
2106
+ */
2107
+ if ((len == 0 ) && (str [copy_bytes - 1 ] == '\0' )) {
2108
+ char cr = '\n' ;
2109
+
2110
+ if (copy_to_user (context -> buf + context -> actual - 1 ,
2111
+ & cr , 1 ))
2097
2112
context -> actual = - EFAULT ;
2098
- context -> actual += copy_bytes ;
2099
- len -= copy_bytes ;
2100
-
2101
- /*
2102
- * If the terminating NUL is included in the length, then it
2103
- * marks the end of a line and should be replaced with a
2104
- * carriage return.
2105
- */
2106
- if ((len == 0 ) && (str [copy_bytes - 1 ] == '\0' )) {
2107
- char cr = '\n' ;
2108
-
2109
- if (copy_to_user (context -> buf + context -> actual - 1 ,
2110
- & cr , 1 ))
2111
- context -> actual = - EFAULT ;
2112
- }
2113
2113
}
2114
2114
}
2115
2115
@@ -2134,34 +2134,36 @@ vchiq_dump_platform_instances(void *dump_context)
2134
2134
struct vchiq_service * service = state -> services [i ];
2135
2135
struct vchiq_instance * instance ;
2136
2136
2137
- if (service && (service -> base .callback == service_callback )) {
2138
- instance = service -> instance ;
2139
- if (instance )
2140
- instance -> mark = 0 ;
2141
- }
2137
+ if (!service || service -> base .callback != service_callback )
2138
+ continue ;
2139
+
2140
+ instance = service -> instance ;
2141
+ if (instance )
2142
+ instance -> mark = 0 ;
2142
2143
}
2143
2144
2144
2145
for (i = 0 ; i < state -> unused_service ; i ++ ) {
2145
2146
struct vchiq_service * service = state -> services [i ];
2146
2147
struct vchiq_instance * instance ;
2147
2148
2148
- if (service && (service -> base .callback == service_callback )) {
2149
- instance = service -> instance ;
2150
- if (instance && !instance -> mark ) {
2151
- len = snprintf (buf , sizeof (buf ),
2152
- "Instance %pK: pid %d,%s completions %d/%d" ,
2153
- instance , instance -> pid ,
2154
- instance -> connected ? " connected, " :
2155
- "" ,
2156
- instance -> completion_insert -
2157
- instance -> completion_remove ,
2158
- MAX_COMPLETIONS );
2159
-
2160
- vchiq_dump (dump_context , buf , len + 1 );
2161
-
2162
- instance -> mark = 1 ;
2163
- }
2164
- }
2149
+ if (!service || service -> base .callback != service_callback )
2150
+ continue ;
2151
+
2152
+ instance = service -> instance ;
2153
+ if (!instance || instance -> mark )
2154
+ continue ;
2155
+
2156
+ len = snprintf (buf , sizeof (buf ),
2157
+ "Instance %pK: pid %d,%s completions %d/%d" ,
2158
+ instance , instance -> pid ,
2159
+ instance -> connected ? " connected, " :
2160
+ "" ,
2161
+ instance -> completion_insert -
2162
+ instance -> completion_remove ,
2163
+ MAX_COMPLETIONS );
2164
+
2165
+ vchiq_dump (dump_context , buf , len + 1 );
2166
+ instance -> mark = 1 ;
2165
2167
}
2166
2168
}
2167
2169
0 commit comments