Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/libbb/procps.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/libbb/procps.c
r3232 r3621 206 206 // ..... 207 207 208 char *tp = buf, *p;208 char *tp, *p; 209 209 210 210 #define SCAN(S, X) \ 211 if ( strncmp(tp, S, sizeof(S)-1) == 0) {\212 tp = skip_whitespace(tp + sizeof(S)-1);\211 if ((tp = is_prefixed_with(buf, S)) != NULL) { \ 212 tp = skip_whitespace(tp); \ 213 213 total->X += currec.X = fast_strtoul_10(&tp); \ 214 214 continue; \ … … 248 248 tp = skip_whitespace(skip_fields(tp, 4)); 249 249 // filter out /dev/something (something != zero) 250 if ( strncmp(tp, "/dev/", 5) != 0|| strcmp(tp, "/dev/zero\n") == 0) {250 if (!is_prefixed_with(tp, "/dev/") || strcmp(tp, "/dev/zero\n") == 0) { 251 251 if (currec.smap_mode[1] == 'w') { 252 252 currec.mapped_rw = currec.smap_size; … … 284 284 #endif 285 285 286 void BUG_comm_size(void);287 286 procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags) 288 287 { … … 386 385 continue;*/ 387 386 cp[0] = '\0'; 388 if (sizeof(sp->comm) < 16) 389 BUG_comm_size(); 387 BUILD_BUG_ON(sizeof(sp->comm) < 16); 390 388 comm1 = strchr(buf, '('); 391 389 /*if (comm1)*/ … … 498 496 char *tp; 499 497 #define SCAN_TWO(str, name, statement) \ 500 if ( strncmp(buf, str, sizeof(str)-1) == 0) { \501 tp = skip_whitespace( buf + sizeof(str)-1); \498 if ((tp = is_prefixed_with(buf, str)) != NULL) { \ 499 tp = skip_whitespace(tp); \ 502 500 sscanf(tp, "%u", &sp->name); \ 503 501 statement; \ … … 555 553 if (flags & PSSCAN_ARGVN) { 556 554 sp->argv_len = n; 557 sp->argv0 = xmalloc(n + 1); 558 memcpy(sp->argv0, buf, n + 1); 555 sp->argv0 = xmemdup(buf, n + 1); 559 556 /* sp->argv0[n] = '\0'; - buf has it */ 560 557 } else { … … 592 589 sz--; 593 590 } 591 if (base[0] == '-') /* "-sh" (login shell)? */ 592 base++; 594 593 595 594 /* If comm differs from argv0, prepend "{comm} ". 596 595 * It allows to see thread names set by prctl(PR_SET_NAME). 597 596 */ 598 if ( base[0] == '-') /* "-sh" (login shell)? */599 base++;597 if (!comm) 598 return; 600 599 comm_len = strlen(comm); 601 600 /* Why compare up to comm_len, not COMM_LEN-1? … … 615 614 buf[col - 1] = '\0'; 616 615 } 617 618 616 } else { 619 snprintf(buf, col, "[%s]", comm );617 snprintf(buf, col, "[%s]", comm ? comm : "?"); 620 618 } 621 619 }
Note:
See TracChangeset
for help on using the changeset viewer.