mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Codestyle fix
This commit is contained in:
parent
e99de21e95
commit
465cf9c4bb
|
@ -25,5 +25,8 @@ There are two different sets of unit tests which demonstrate how to use differen
|
|||
* `tests/guetzli_sapi_test.cc` - example usage of Guetzli sandboxed API.
|
||||
* `tests/guetzli_transaction_test.cc` - example usage of Guetzli transaction.
|
||||
|
||||
To run tests use following command:
|
||||
`bazel test ...`
|
||||
|
||||
Also, there is an example of custom security policy for your sandbox in
|
||||
`guetzli_sandbox.h`
|
||||
|
|
|
@ -154,7 +154,7 @@ sapi::StatusOr<ImageData> ReadPNG(const std::string& data) {
|
|||
|
||||
xsize = png_get_image_width(png_ptr, info_ptr);
|
||||
ysize = png_get_image_height(png_ptr, info_ptr);
|
||||
rgb.resize(3 * (xsize) * (ysize));
|
||||
rgb.resize(3 * xsize * ysize);
|
||||
|
||||
const int components = png_get_channels(png_ptr, info_ptr);
|
||||
switch (components) {
|
||||
|
@ -162,7 +162,7 @@ sapi::StatusOr<ImageData> ReadPNG(const std::string& data) {
|
|||
// GRAYSCALE
|
||||
for (int y = 0; y < ysize; ++y) {
|
||||
const uint8_t* row_in = row_pointers[y];
|
||||
uint8_t* row_out = &(rgb)[3 * y * (xsize)];
|
||||
uint8_t* row_out = &rgb[3 * y * xsize];
|
||||
for (int x = 0; x < xsize; ++x) {
|
||||
const uint8_t gray = row_in[x];
|
||||
row_out[3 * x + 0] = gray;
|
||||
|
@ -176,7 +176,7 @@ sapi::StatusOr<ImageData> ReadPNG(const std::string& data) {
|
|||
// GRAYSCALE + ALPHA
|
||||
for (int y = 0; y < ysize; ++y) {
|
||||
const uint8_t* row_in = row_pointers[y];
|
||||
uint8_t* row_out = &(rgb)[3 * y * (xsize)];
|
||||
uint8_t* row_out = &rgb[3 * y * xsize];
|
||||
for (int x = 0; x < xsize; ++x) {
|
||||
const uint8_t gray = BlendOnBlack(row_in[2 * x], row_in[2 * x + 1]);
|
||||
row_out[3 * x + 0] = gray;
|
||||
|
@ -190,8 +190,8 @@ sapi::StatusOr<ImageData> ReadPNG(const std::string& data) {
|
|||
// RGB
|
||||
for (int y = 0; y < ysize; ++y) {
|
||||
const uint8_t* row_in = row_pointers[y];
|
||||
uint8_t* row_out = &(rgb)[3 * y * (xsize)];
|
||||
memcpy(row_out, row_in, 3 * (xsize));
|
||||
uint8_t* row_out = &rgb[3 * y * xsize];
|
||||
memcpy(row_out, row_in, 3 * xsize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ sapi::StatusOr<ImageData> ReadPNG(const std::string& data) {
|
|||
// RGBA
|
||||
for (int y = 0; y < ysize; ++y) {
|
||||
const uint8_t* row_in = row_pointers[y];
|
||||
uint8_t* row_out = &(rgb)[3 * y * (xsize)];
|
||||
uint8_t* row_out = &rgb[3 * y * xsize];
|
||||
for (int x = 0; x < xsize; ++x) {
|
||||
const uint8_t alpha = row_in[4 * x + 3];
|
||||
row_out[3 * x + 0] = BlendOnBlack(row_in[4 * x + 0], alpha);
|
||||
|
|
|
@ -107,6 +107,7 @@ absl::Status GuetzliTransaction::LinkOutFile(int out_fd) const {
|
|||
|
||||
std::stringstream path;
|
||||
path << "/proc/self/fd/" << out_fd;
|
||||
|
||||
if (linkat(AT_FDCWD, path.str().c_str(), AT_FDCWD, params_.out_file,
|
||||
AT_SYMLINK_FOLLOW) < 0) {
|
||||
std::stringstream error;
|
||||
|
|
|
@ -42,12 +42,11 @@ struct TransactionParams {
|
|||
// Create a new one for each processing operation
|
||||
class GuetzliTransaction : public sapi::Transaction {
|
||||
public:
|
||||
GuetzliTransaction(TransactionParams params)
|
||||
GuetzliTransaction(TransactionParams params, int retry_count = 0)
|
||||
: sapi::Transaction(std::make_unique<GuetzliSapiSandbox>())
|
||||
, params_(std::move(params))
|
||||
{
|
||||
//TODO: Add retry count as a parameter
|
||||
sapi::Transaction::set_retry_count(kDefaultTransactionRetryCount);
|
||||
sapi::Transaction::set_retry_count(retry_count);
|
||||
sapi::Transaction::SetTimeLimit(0); // Infinite time limit
|
||||
}
|
||||
|
||||
|
@ -59,8 +58,6 @@ class GuetzliTransaction : public sapi::Transaction {
|
|||
|
||||
const TransactionParams params_;
|
||||
ImageType image_type_ = ImageType::kJpeg;
|
||||
|
||||
static const int kDefaultTransactionRetryCount = 0;
|
||||
};
|
||||
|
||||
} // namespace sandbox
|
||||
|
|
Loading…
Reference in New Issue
Block a user