Print this page
12276 smatch-clean sockfs


1123         int             error, perror;
1124 
1125         nl7c_uri_data++;
1126 
1127         if (uri == NULL) {
1128                 /* Socket & NL7C out of sync, disable NL7C */
1129                 sti->sti_nl7c_flags = 0;
1130                 nl7c_uri_NULL1++;
1131                 return (-1);
1132         }
1133 
1134         if (sti->sti_nl7c_flags & NL7C_WAITWRITE) {
1135                 sti->sti_nl7c_flags &= ~NL7C_WAITWRITE;
1136                 first = B_TRUE;
1137         } else {
1138                 first = B_FALSE;
1139         }
1140 
1141         alloc = kmem_alloc(sz, KM_SLEEP);
1142         URI_RD_ADD(uri, rdp, sz, -1);
1143         if (rdp == NULL) {
1144                 error = ENOMEM;
1145                 goto fail;
1146         }
1147 
1148         if (uri->hash != URI_TEMP && uri->count > nca_max_cache_size) {
1149                 uri_delete(uri);
1150                 uri->hash = URI_TEMP;
1151         }
1152         data = alloc;
1153         alloc = NULL;
1154         rdp->data.kmem = data;
1155         atomic_add_64(&nl7c_uri_bytes, sz);
1156 
1157         bp = data;
1158         while (uio->uio_resid > 0) {
1159                 iov = uio->uio_iov;
1160                 if ((cnt = iov->iov_len) == 0) {
1161                         goto next;
1162                 }
1163                 cnt = MIN(cnt, uio->uio_resid);
1164                 error = xcopyin(iov->iov_base, bp, cnt);
1165                 if (error)
1166                         goto fail;


1359                         if (vp->v_type != VREG) {
1360                                 error = EINVAL;
1361                                 goto fail;
1362                         }
1363                         VN_HOLD(vp);
1364 
1365                         /* Read max_rem bytes from file for prefetch */
1366                         if (nl7c_use_kmem) {
1367                                 max = cnt;
1368                         } else {
1369                                 max = MAXBSIZE * nl7c_file_prefetch;
1370                         }
1371                         alloc = nl7c_readfile(fp, &off, &cnt, max, &error);
1372                         if (alloc == NULL)
1373                                 goto fail;
1374 
1375                         releasef(sfvp->sfv_fd);
1376                         fp = NULL;
1377                 }
1378                 URI_RD_ADD(uri, rdp, cnt, -1);
1379                 if (rdp == NULL) {
1380                         error = ENOMEM;
1381                         goto fail;
1382                 }
1383                 data = alloc;
1384                 alloc = NULL;
1385                 rdp->data.kmem = data;
1386                 total_count += cnt;
1387                 if (uri->hash != URI_TEMP && total_count > nca_max_cache_size) {
1388                         uri_delete(uri);
1389                         uri->hash = URI_TEMP;
1390                 }
1391 
1392                 /* Response parse */
1393                 perror = nl7c_resp_parse(so, uri, data, len);
1394 
1395                 /* Send kmem data out the connection */
1396                 error = uri_rd_response(so, uri, rdp, first);
1397 
1398                 if (error)
1399                         goto fail;
1400 
1401                 if (sfvp->sfv_fd != SFV_FD_SELF) {
1402                         /*
1403                          * File descriptor, if any bytes left save vnode_t.
1404                          */
1405                         if (len > cnt) {
1406                                 /* More file data so add it */
1407                                 URI_RD_ADD(uri, rdp, len - cnt, off);
1408                                 if (rdp == NULL) {
1409                                         error = ENOMEM;
1410                                         goto fail;
1411                                 }
1412                                 rdp->data.vnode = vp;
1413 
1414                                 /* Send vnode data out the connection */
1415                                 error = uri_rd_response(so, uri, rdp, first);
1416                         } else {
1417                                 /* All file data fit in the prefetch */
1418                                 VN_RELE(vp);
1419                         }
1420                         *fileoff += len;
1421                         vp = NULL;
1422                 }
1423                 *xfer += len;
1424                 sfvp++;
1425 
1426                 if (first)
1427                         first = B_FALSE;
1428         }
1429         if (total_count > 0) {
1430                 atomic_add_64(&nl7c_uri_bytes, total_count);
1431         }




1123         int             error, perror;
1124 
1125         nl7c_uri_data++;
1126 
1127         if (uri == NULL) {
1128                 /* Socket & NL7C out of sync, disable NL7C */
1129                 sti->sti_nl7c_flags = 0;
1130                 nl7c_uri_NULL1++;
1131                 return (-1);
1132         }
1133 
1134         if (sti->sti_nl7c_flags & NL7C_WAITWRITE) {
1135                 sti->sti_nl7c_flags &= ~NL7C_WAITWRITE;
1136                 first = B_TRUE;
1137         } else {
1138                 first = B_FALSE;
1139         }
1140 
1141         alloc = kmem_alloc(sz, KM_SLEEP);
1142         URI_RD_ADD(uri, rdp, sz, -1);




1143 
1144         if (uri->hash != URI_TEMP && uri->count > nca_max_cache_size) {
1145                 uri_delete(uri);
1146                 uri->hash = URI_TEMP;
1147         }
1148         data = alloc;
1149         alloc = NULL;
1150         rdp->data.kmem = data;
1151         atomic_add_64(&nl7c_uri_bytes, sz);
1152 
1153         bp = data;
1154         while (uio->uio_resid > 0) {
1155                 iov = uio->uio_iov;
1156                 if ((cnt = iov->iov_len) == 0) {
1157                         goto next;
1158                 }
1159                 cnt = MIN(cnt, uio->uio_resid);
1160                 error = xcopyin(iov->iov_base, bp, cnt);
1161                 if (error)
1162                         goto fail;


1355                         if (vp->v_type != VREG) {
1356                                 error = EINVAL;
1357                                 goto fail;
1358                         }
1359                         VN_HOLD(vp);
1360 
1361                         /* Read max_rem bytes from file for prefetch */
1362                         if (nl7c_use_kmem) {
1363                                 max = cnt;
1364                         } else {
1365                                 max = MAXBSIZE * nl7c_file_prefetch;
1366                         }
1367                         alloc = nl7c_readfile(fp, &off, &cnt, max, &error);
1368                         if (alloc == NULL)
1369                                 goto fail;
1370 
1371                         releasef(sfvp->sfv_fd);
1372                         fp = NULL;
1373                 }
1374                 URI_RD_ADD(uri, rdp, cnt, -1);




1375                 data = alloc;
1376                 alloc = NULL;
1377                 rdp->data.kmem = data;
1378                 total_count += cnt;
1379                 if (uri->hash != URI_TEMP && total_count > nca_max_cache_size) {
1380                         uri_delete(uri);
1381                         uri->hash = URI_TEMP;
1382                 }
1383 
1384                 /* Response parse */
1385                 perror = nl7c_resp_parse(so, uri, data, len);
1386 
1387                 /* Send kmem data out the connection */
1388                 error = uri_rd_response(so, uri, rdp, first);
1389 
1390                 if (error)
1391                         goto fail;
1392 
1393                 if (sfvp->sfv_fd != SFV_FD_SELF) {
1394                         /*
1395                          * File descriptor, if any bytes left save vnode_t.
1396                          */
1397                         if (len > cnt) {
1398                                 /* More file data so add it */
1399                                 URI_RD_ADD(uri, rdp, len - cnt, off);




1400                                 rdp->data.vnode = vp;
1401 
1402                                 /* Send vnode data out the connection */
1403                                 error = uri_rd_response(so, uri, rdp, first);
1404                         } else {
1405                                 /* All file data fit in the prefetch */
1406                                 VN_RELE(vp);
1407                         }
1408                         *fileoff += len;
1409                         vp = NULL;
1410                 }
1411                 *xfer += len;
1412                 sfvp++;
1413 
1414                 if (first)
1415                         first = B_FALSE;
1416         }
1417         if (total_count > 0) {
1418                 atomic_add_64(&nl7c_uri_bytes, total_count);
1419         }