mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
update cdatapack utilities to check open success
Summary: Update cdatapack_dump and cdatapack_get to check the return value from `open_datapack()` to confirm if they actually successfully opened the file. Previously these programs would segfault if invoked with a non-existent path. Reviewed By: quark-zju Differential Revision: D8131017 fbshipit-source-id: 90800de57430efd176b8e71fa84161f7b288e375
This commit is contained in:
parent
a6fcceea31
commit
7233f0dfb1
@ -1,5 +1,12 @@
|
||||
LDFLAGS=-llz4
|
||||
LDFLAGS = -llz4 -lcrypto
|
||||
CC = gcc
|
||||
CFLAGS = -g -std=c99 -Wall -Werror -I.. -I../..
|
||||
|
||||
all: cdatapack_dump cdatapack_get
|
||||
|
||||
cdatapack_dump: cdatapack_dump.o cdatapack.o
|
||||
|
||||
.o.c:
|
||||
cdatapack_get: cdatapack_get.o cdatapack.o
|
||||
|
||||
%.o: %.c cdatapack.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
@ -43,6 +43,10 @@ int main(int argc, char *argv[]) {
|
||||
data_path, strlen(data_path));
|
||||
free(data_path);
|
||||
free(idx_path);
|
||||
if (handle->status != DATAPACK_HANDLE_OK) {
|
||||
fprintf(stderr, "failed to open pack: %d\n", handle->status);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const uint8_t *ptr = handle->data_mmap;
|
||||
const uint8_t *end = ptr + handle->data_file_sz;
|
||||
|
@ -53,6 +53,10 @@ int main(int argc, char *argv[]) {
|
||||
data_path, strlen(data_path));
|
||||
free(data_path);
|
||||
free(idx_path);
|
||||
if (handle->status != DATAPACK_HANDLE_OK) {
|
||||
fprintf(stderr, "failed to open pack: %d\n", handle->status);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t binhash[NODE_SZ];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user