core(M4): полировка по нитам финального ревью
- fglair-discover: fchmod 0600 и при перезаписи существующего --out. - fglctl: #include <cstdlib>; точная проверка обрезки config (n == sizeof-1 && !feof); валидация 'monitor <sec>' (endptr/errno). - docs: отчёт soak — формулировка «ответы на batch GET»; индекс reports. Ревью M4 независимым агентом: 2 круга, APPROVED.
This commit is contained in:
+15
-2
@@ -10,6 +10,7 @@
|
||||
// "lanip_key_id": N, "model": "AP-WC1E", ...}
|
||||
#include <cerrno>
|
||||
#include <chrono>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <thread>
|
||||
@@ -70,7 +71,7 @@ bool load_config(const char* path, fgl::aircon::Config* cfg,
|
||||
}
|
||||
static char buf[4096];
|
||||
size_t n = fread(buf, 1, sizeof(buf) - 1, f);
|
||||
bool truncated = !feof(f);
|
||||
bool truncated = n == sizeof(buf) - 1 && !feof(f);
|
||||
fclose(f);
|
||||
buf[n] = '\0';
|
||||
if (truncated) {
|
||||
@@ -181,7 +182,18 @@ int main(int argc, char** argv) {
|
||||
const char* cmd = argv[2];
|
||||
int rc = 0;
|
||||
if (strcmp(cmd, "monitor") == 0) {
|
||||
int secs = argc > 3 ? atoi(argv[3]) : 60;
|
||||
int secs = 60;
|
||||
if (argc > 3) {
|
||||
char* end = nullptr;
|
||||
errno = 0;
|
||||
long v = strtol(argv[3], &end, 10);
|
||||
if (errno != 0 || end == argv[3] || *end != '\0' || v < 0) {
|
||||
fprintf(stderr, "Некорректная длительность: %s\n", argv[3]);
|
||||
rc = 2;
|
||||
goto cleanup;
|
||||
}
|
||||
secs = static_cast<int>(v);
|
||||
}
|
||||
if ((rc = wait_online(s, 15000)) == 0) {
|
||||
s->batch_begin();
|
||||
for (auto* info = fgl::aircon::prop_info_begin(tmpl);
|
||||
@@ -249,6 +261,7 @@ int main(int argc, char** argv) {
|
||||
rc = 2;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
print_stats(s);
|
||||
s->stop();
|
||||
delete s;
|
||||
|
||||
Reference in New Issue
Block a user