Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 696692a3 authored by Sen Jiang's avatar Sen Jiang
Browse files

applypatch: Add a Makefile to build imgdiff in Chrome OS.

Also fixed some warnings and added check for target_len.

Test: mma; emerge-peppy imgdiff; emerge-nyan imgdiff; sudo emerge imgdiff
Bug: 26866274

Change-Id: Ifbcd3afd6701c769ccf626e33ed94461706f7ee6
parent c213a7c1
Loading
Loading
Loading
Loading

applypatch/Makefile

0 → 100644
+32 −0
Original line number Original line Diff line number Diff line
# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This file is for building imgdiff in Chrome OS.

CPPFLAGS += -iquote..
CXXFLAGS += -std=c++11 -O3 -Wall -Werror
LDLIBS += -lbz2 -lz

.PHONY: all clean

all: imgdiff libimgpatch.a

clean:
	rm -f *.o imgdiff libimgpatch.a

imgdiff: imgdiff.o bsdiff.o utils.o
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDLIBS) -o $@ $^

libimgpatch.a: imgpatch.o bspatch.o utils.o
	${AR} rcs $@ $^
+1 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
#ifndef _APPLYPATCH_H
#ifndef _APPLYPATCH_H
#define _APPLYPATCH_H
#define _APPLYPATCH_H


#include <stdint.h>
#include <sys/stat.h>
#include <sys/stat.h>


#include <vector>
#include <vector>
+0 −1
Original line number Original line Diff line number Diff line
@@ -224,7 +224,6 @@ static void offtout(off_t x,u_char *buf)
int bsdiff(u_char* old, off_t oldsize, off_t** IP, u_char* newdata, off_t newsize,
int bsdiff(u_char* old, off_t oldsize, off_t** IP, u_char* newdata, off_t newsize,
           const char* patch_filename)
           const char* patch_filename)
{
{
	int fd;
	off_t *I;
	off_t *I;
	off_t scan,pos,len;
	off_t scan,pos,len;
	off_t lastscan,lastpos,lastoffset;
	off_t lastscan,lastpos,lastoffset;
+0 −1
Original line number Original line Diff line number Diff line
@@ -182,7 +182,6 @@ int ApplyBSDiffPatchMem(const unsigned char* old_data, ssize_t old_size,


    off_t oldpos = 0, newpos = 0;
    off_t oldpos = 0, newpos = 0;
    off_t ctrl[3];
    off_t ctrl[3];
    off_t len_read;
    int i;
    int i;
    unsigned char buf[24];
    unsigned char buf[24];
    while (newpos < new_size) {
    while (newpos < new_size) {
+0 −2
Original line number Original line Diff line number Diff line
@@ -598,7 +598,6 @@ int ReconstructDeflateChunk(ImageChunk* chunk) {
    return -1;
    return -1;
  }
  }


  size_t p = 0;
  unsigned char* out = reinterpret_cast<unsigned char*>(malloc(BUFFER_SIZE));
  unsigned char* out = reinterpret_cast<unsigned char*>(malloc(BUFFER_SIZE));


  // We only check two combinations of encoder parameters:  level 6
  // We only check two combinations of encoder parameters:  level 6
@@ -844,7 +843,6 @@ int main(int argc, char** argv) {
  }
  }


  if (argc != 4) {
  if (argc != 4) {
    usage:
    printf("usage: %s [-z] [-b <bonus-file>] <src-img> <tgt-img> <patch-file>\n",
    printf("usage: %s [-z] [-b <bonus-file>] <src-img> <tgt-img> <patch-file>\n",
            argv[0]);
            argv[0]);
    return 2;
    return 2;
Loading